From 3b56936b6bf282df89a02ba98d16fe4c23331492 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Wed, 3 Mar 2021 17:13:28 +0300 Subject: [PATCH] Fixed project search field clearing --- .../create-task-page/project-search-field.tsx | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/cvat-ui/src/components/create-task-page/project-search-field.tsx b/cvat-ui/src/components/create-task-page/project-search-field.tsx index 450cbf953d1..9bab28e2b4f 100644 --- a/cvat-ui/src/components/create-task-page/project-search-field.tsx +++ b/cvat-ui/src/components/create-task-page/project-search-field.tsx @@ -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]);