Skip to content

Commit

Permalink
Fixed project search field clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
ActiveChooN committed Mar 3, 2021
1 parent 9b62b71 commit 3b56936
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions cvat-ui/src/components/create-task-page/project-search-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,23 @@ export default function ProjectSearchField(props: Props): JSX.Element {
};

useEffect(() => {
if (value && !projects.filter((project) => project.id === value).length) {
core.projects.get({ id: value }).then((result: Project[]) => {
const [project] = result;
setProjects([
...projects,
{
id: project.id,
name: project.name,
},
]);
setSearchPhrase(project.name);
onSelect(project.id);
});
if (value) {
if (!projects.filter((project) => project.id === value).length) {
core.projects.get({ id: value }).then((result: Project[]) => {
const [project] = result;
setProjects([
...projects,
{
id: project.id,
name: project.name,
},
]);
setSearchPhrase(project.name);
onSelect(project.id);
});
}
} else {
setSearchPhrase('');
}
}, [value]);

Expand Down

0 comments on commit 3b56936

Please sign in to comment.