Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Focus lost after modifying filter or search params #696

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions client/src/pages/databases/collections/search/VectorInputBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,6 @@ export default function VectorInputBox(props: VectorInputBoxProps) {
onChangeRef.current = onChange;
fieldRef.current = field;
searchParamsRef.current = searchParams;

if (editor.current) {
// only data replace should trigger this, otherwise, let cm handle the state
if (editor.current.state.doc.toString() !== data) {
editor.current.dispatch({
changes: {
from: 0,
to: data.length + 1,
insert: data,
},
});
}
}
}, [JSON.stringify(searchParams), onChange]);

const getVectorById = (text: string) => {
Expand Down Expand Up @@ -293,14 +280,15 @@ export default function VectorInputBox(props: VectorInputBoxProps) {
editor.current.dispatch({
selection: { anchor: endPos },
});

editor.current.focus();

return () => {
view.destroy();
editor.current = undefined;
};
}
}, [JSON.stringify(field), getVectorById]);
}, [JSON.stringify({ field, data })]);

useEffect(() => {
// dispatch dark mode change to editor
Expand Down
1 change: 0 additions & 1 deletion client/src/pages/search/SearchParams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ const SearchParams: FC<SearchParamsProps> = ({
isInt: false,
required: false,
handleChange: value => {
console.log(value, typeof value);
handleInputChange('radius', value);
},
className: classes.inlineInput,
Expand Down
Loading