From 25663322e3e677a25f8844421d610fafa7947aec Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Thu, 20 Mar 2025 19:47:08 +0300 Subject: [PATCH] F: Replace clickOutside with onBlur trigger for dropdowns --- .../src/components/dropdown/use-dropdown.ts | 11 +++++--- .../pages/manuals-page/topics-dropdown.tsx | 1 + .../components/editor-library-item.tsx | 2 +- .../features/library/components/menu-role.tsx | 2 +- .../library/components/mini-selector-oss.tsx | 7 ++++- .../pick-location/select-location-context.tsx | 7 ++++- .../library/components/pick-schema.tsx | 2 +- .../components/select-access-policy.tsx | 2 +- .../library/components/select-item-type.tsx | 2 +- .../components/select-location-head.tsx | 7 ++++- .../pages/library-page/toolbar-search.tsx | 10 +++++-- .../editor-oss-graph/node-context-menu.tsx | 15 ++++++++-- .../oss/pages/oss-page/menu-edit-oss.tsx | 12 ++++---- .../features/oss/pages/oss-page/menu-main.tsx | 16 +++++------ .../editor-rslist/toolbar-rslist.tsx | 10 +++---- .../pages/rsform-page/menu-edit-schema.tsx | 24 ++++++++-------- .../rsform/pages/rsform-page/menu-main.tsx | 22 +++++++-------- .../view-constituents/select-graph-filter.tsx | 2 +- .../view-constituents/select-match-mode.tsx | 2 +- .../frontend/src/hooks/use-clicked-outside.ts | 28 ------------------- 20 files changed, 94 insertions(+), 90 deletions(-) delete mode 100644 rsconcept/frontend/src/hooks/use-clicked-outside.ts diff --git a/rsconcept/frontend/src/components/dropdown/use-dropdown.ts b/rsconcept/frontend/src/components/dropdown/use-dropdown.ts index df14cc1f..0364a66c 100644 --- a/rsconcept/frontend/src/components/dropdown/use-dropdown.ts +++ b/rsconcept/frontend/src/components/dropdown/use-dropdown.ts @@ -2,18 +2,21 @@ import { useRef, useState } from 'react'; -import { useClickedOutside } from '@/hooks/use-clicked-outside'; - export function useDropdown() { const [isOpen, setIsOpen] = useState(false); - const ref = useRef(null); + const ref = useRef(null); - useClickedOutside(isOpen, ref, () => setIsOpen(false)); + function handleBlur(event: React.FocusEvent) { + if (!ref.current?.contains(event.relatedTarget as Node)) { + setIsOpen(false); + } + } return { ref, isOpen, setIsOpen, + handleBlur, toggle: () => setIsOpen(!isOpen), hide: () => setIsOpen(false) }; diff --git a/rsconcept/frontend/src/features/help/pages/manuals-page/topics-dropdown.tsx b/rsconcept/frontend/src/features/help/pages/manuals-page/topics-dropdown.tsx index 09e7b236..334394b5 100644 --- a/rsconcept/frontend/src/features/help/pages/manuals-page/topics-dropdown.tsx +++ b/rsconcept/frontend/src/features/help/pages/manuals-page/topics-dropdown.tsx @@ -30,6 +30,7 @@ export function TopicsDropdown({ activeTopic, onChangeTopic }: TopicsDropdownPro return (
-
+
{ownerSelector.isOpen ? (
diff --git a/rsconcept/frontend/src/features/library/components/menu-role.tsx b/rsconcept/frontend/src/features/library/components/menu-role.tsx index c695311a..0ceb3d3d 100644 --- a/rsconcept/frontend/src/features/library/components/menu-role.tsx +++ b/rsconcept/frontend/src/features/library/components/menu-role.tsx @@ -44,7 +44,7 @@ export function MenuRole({ isOwned, isEditor }: MenuRoleProps) { } return ( -
+