From e5aaab285d540ae6c114946d50e66aeed05cb802 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Fri, 25 Apr 2025 09:02:18 -0500 Subject: [PATCH] Refine admin menu tooltip interaction --- src/admin/AdminAppMenu.tsx | 4 +- src/app/AppViewSwitcher.tsx | 66 ++++++++++--------- src/components/SwitcherItem.tsx | 2 +- src/components/primitives/KeyCommand.tsx | 6 +- .../primitives/TooltipPrimitive.tsx | 2 +- 5 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/admin/AdminAppMenu.tsx b/src/admin/AdminAppMenu.tsx index 69d60ba5..4e073840 100644 --- a/src/admin/AdminAppMenu.tsx +++ b/src/admin/AdminAppMenu.tsx @@ -97,7 +97,7 @@ export default function AdminAppMenu({ {photosCountNeedSync} , @@ -201,7 +201,7 @@ export default function AdminAppMenu({ className="translate-x-[1px] translate-y-[1px]" size={13} /> - : { + if (isAdminMenuOpen) { + hasAdminMenuOpenedOnce.current = true; + } else if (hasAdminMenuOpenedOnce.current) { + // Blur admin menu button to avoid tooltip on dismiss + setTimeout(() => { + if (document.activeElement instanceof HTMLElement) { + document.activeElement.blur(); + } + }, 50); + } + }, [isAdminMenuOpen]); + const renderItemFeed = } href={PATH_FEED_INFERRED} active={currentSelection === 'feed'} - tooltip={!isAdminMenuOpen - ? { - content: 'Feed', - keyCommand: 'F', - } - : undefined} + tooltip={{ + content: 'Feed', + keyCommand: 'F', + }} noPadding />; @@ -50,20 +62,20 @@ export default function AppViewSwitcher({ icon={} href={PATH_GRID_INFERRED} active={currentSelection === 'grid'} - tooltip={!isAdminMenuOpen - ? { - content: 'Grid', - keyCommand: 'G', - } - : undefined} + tooltip={{ + content: 'Grid', + keyCommand: 'G', + }} noPadding />; return ( -
+
{GRID_HOMEPAGE_ENABLED ? renderItemGrid : renderItemFeed} {GRID_HOMEPAGE_ENABLED ? renderItemFeed : renderItemGrid} @@ -73,9 +85,7 @@ export default function AppViewSwitcher({ icon={} isInteractive={false} noPadding - tooltip={!isAdminMenuOpen - ? { content: 'Admin Menu' } - : undefined} + tooltip={{ content: 'Admin Menu' }} />} {isUserSignedIn && } - tooltip={!isAdminMenuOpen - ? { content: 'Admin Menu' } - : undefined} + tooltip={{ content: !isAdminMenuOpen ? 'Admin Menu' : undefined }} noPadding />} @@ -93,13 +101,11 @@ export default function AppViewSwitcher({ } onClick={() => setIsCommandKOpen?.(true)} - tooltip={!isAdminMenuOpen - ? { - content: 'Search', - keyCommand: 'K', - keyCommandModifier: '⌘', - } - : undefined} + tooltip={{ + content: 'Search', + keyCommand: 'K', + keyCommandModifier: '⌘', + }} />
diff --git a/src/components/SwitcherItem.tsx b/src/components/SwitcherItem.tsx index a678eefa..9178cb4f 100644 --- a/src/components/SwitcherItem.tsx +++ b/src/components/SwitcherItem.tsx @@ -72,7 +72,7 @@ export default function SwitcherItem({ ? {content} diff --git a/src/components/primitives/KeyCommand.tsx b/src/components/primitives/KeyCommand.tsx index 290563f0..3630d963 100644 --- a/src/components/primitives/KeyCommand.tsx +++ b/src/components/primitives/KeyCommand.tsx @@ -19,7 +19,11 @@ export default function KeyCommand({ {keys.map((key) => ( {key} diff --git a/src/components/primitives/TooltipPrimitive.tsx b/src/components/primitives/TooltipPrimitive.tsx index ddcd86d5..000cdd0f 100644 --- a/src/components/primitives/TooltipPrimitive.tsx +++ b/src/components/primitives/TooltipPrimitive.tsx @@ -49,7 +49,7 @@ export default function TooltipPrimitive({ }); const classNameTrigger = clsx( - 'cursor-default inline-block', + 'cursor-default inline-flex', classNameTriggerProp, );