From 5d47b7510e047e69db7fcf2e71b6953c54988112 Mon Sep 17 00:00:00 2001 From: Himanshu Sahu Date: Fri, 31 Oct 2025 18:58:53 +0530 Subject: [PATCH] fix(ui): made blog category select clickable and navigate correctly on mobile --- .../src/Common/BaseLinkTabs/index.tsx | 2 +- .../Common/Select/StatelessSelect/index.tsx | 41 ++++++++++++++++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/packages/ui-components/src/Common/BaseLinkTabs/index.tsx b/packages/ui-components/src/Common/BaseLinkTabs/index.tsx index fd39e5fd8a234..f334f71cd1766 100644 --- a/packages/ui-components/src/Common/BaseLinkTabs/index.tsx +++ b/packages/ui-components/src/Common/BaseLinkTabs/index.tsx @@ -34,7 +34,7 @@ const BaseLinkTabs: FC = ({ ))} - + {/* StatelessSelect now handles client-side navigation internally */} ({ className, ariaLabel, disabled = false, - as: Component = 'div', }: StatelessSelectProps) => { const id = useId(); + const detailsRef = useRef(null); const mappedValues = useMemo(() => { let mappedValues = values; @@ -54,6 +55,20 @@ const StatelessSelect = ({ [mappedValues, defaultValue] ); + // closing behaviour for outside click + useEffect(() => { + const handleOutside = (e: MouseEvent) => { + if ( + detailsRef.current && + !detailsRef.current.contains(e.target as Node) + ) { + detailsRef.current.open = false; + } + }; + document.addEventListener('pointerdown', handleOutside); + return () => document.removeEventListener('pointerdown', handleOutside); + }, []); + return (
({ )} -
+
({ {items.map( ({ value, label, iconImage, disabled: itemDisabled }) => ( - ({ [styles.selected]: value === defaultValue, })} aria-disabled={itemDisabled || disabled} + onClick={e => { + // Allow ctrl/cmd/middle click to open new tab + if (e.metaKey || e.ctrlKey || e.button === 1) { + return; + } + e.preventDefault(); + + if (detailsRef.current) { + detailsRef.current.open = false; + } + + // Client-side navigation for internal links + if (typeof window !== 'undefined') { + window.location.href = value; + } + }} > {iconImage} {label} - + ) )}