From 90295fd620835d5671f2364673546ae3d96bc3b7 Mon Sep 17 00:00:00 2001 From: Wahyu Kurniawan Date: Wed, 6 Mar 2024 13:09:23 +0700 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20use=20dialog?= =?UTF-8?q?=20overlay=20instead=20of=20div?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSearchBarDialog.tsx | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/packages/frontend/src/components/projects/ProjectSearchBar/ProjectSearchBarDialog.tsx b/packages/frontend/src/components/projects/ProjectSearchBar/ProjectSearchBarDialog.tsx index 21f31901..a3988ae3 100644 --- a/packages/frontend/src/components/projects/ProjectSearchBar/ProjectSearchBarDialog.tsx +++ b/packages/frontend/src/components/projects/ProjectSearchBar/ProjectSearchBarDialog.tsx @@ -26,28 +26,23 @@ export const ProjectSearchBarDialog = ({ const client = useGQLClient(); const navigate = useNavigate(); - const { - getMenuProps, - getInputProps, - getItemProps, - inputValue, - setInputValue, - } = useCombobox({ - items, - itemToString(item) { - return item ? item.name : ''; - }, - selectedItem, - onSelectedItemChange: ({ selectedItem: newSelectedItem }) => { - if (newSelectedItem) { - setSelectedItem(newSelectedItem); - onClickItem?.(newSelectedItem); - navigate( - `/${newSelectedItem.organization.slug}/projects/${newSelectedItem.id}`, - ); - } - }, - }); + const { getInputProps, getItemProps, inputValue, setInputValue } = + useCombobox({ + items, + itemToString(item) { + return item ? item.name : ''; + }, + selectedItem, + onSelectedItemChange: ({ selectedItem: newSelectedItem }) => { + if (newSelectedItem) { + setSelectedItem(newSelectedItem); + onClickItem?.(newSelectedItem); + navigate( + `/${newSelectedItem.organization.slug}/projects/${newSelectedItem.id}`, + ); + } + }, + }); const debouncedInputValue = useDebounce(inputValue, 500); @@ -74,9 +69,10 @@ export const ProjectSearchBarDialog = ({ return ( -
- -
+ + +
+
} @@ -89,7 +85,7 @@ export const ProjectSearchBarDialog = ({
{/* Content */} -
+
{items.length > 0 ? items.map((item, index) => ( <> @@ -107,8 +103,8 @@ export const ProjectSearchBarDialog = ({ )) : inputValue && }
- -
+
+
);