fix: keep Settings open when dismissing dropdowns
This commit is contained in:
@@ -14,19 +14,35 @@ interface SettingsWindowProps {
|
||||
*/
|
||||
export const SettingsWindow: React.FC<SettingsWindowProps> = ({ open, onOpenChange }) => {
|
||||
const descriptionId = React.useId();
|
||||
const skipNextOverlayClickRef = React.useRef(false);
|
||||
|
||||
const hasOpenFloatingMenu = React.useCallback(() => {
|
||||
if (typeof document === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Boolean(
|
||||
document.querySelector('[data-slot="dropdown-menu-content"][data-state="open"], [data-slot="select-content"][data-state="open"]')
|
||||
);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<DialogPrimitive.Root open={open} onOpenChange={onOpenChange}>
|
||||
<DialogPrimitive.Portal>
|
||||
<DialogPrimitive.Overlay
|
||||
className="fixed inset-0 z-50 bg-black/50 backdrop-blur-md"
|
||||
onPointerDown={(event) => {
|
||||
event.stopPropagation();
|
||||
}}
|
||||
onPointerUp={(event) => {
|
||||
event.stopPropagation();
|
||||
onPointerDown={() => {
|
||||
skipNextOverlayClickRef.current = hasOpenFloatingMenu();
|
||||
}}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
if (skipNextOverlayClickRef.current) {
|
||||
skipNextOverlayClickRef.current = false;
|
||||
return;
|
||||
}
|
||||
if (hasOpenFloatingMenu()) {
|
||||
return;
|
||||
}
|
||||
onOpenChange(false);
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user