F: Do not close dropdown when clicking on interactive child
This commit is contained in:
parent
9f1aa2b4a8
commit
9811d0155e
|
|
@ -7,7 +7,16 @@ export function useDropdown() {
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
function handleBlur(event: React.FocusEvent<HTMLDivElement>) {
|
function handleBlur(event: React.FocusEvent<HTMLDivElement>) {
|
||||||
if (ref.current?.contains(event.relatedTarget as Node)) {
|
const nextTarget = event.relatedTarget as Node | null;
|
||||||
|
if (nextTarget && ref.current?.contains(nextTarget)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep open when focus moves into a popover (e.g., ComboBox menu rendered via portal)
|
||||||
|
if (
|
||||||
|
nextTarget instanceof Element &&
|
||||||
|
(nextTarget.closest("[data-slot='popover-content']") || nextTarget.closest("[data-slot='popover-trigger']"))
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user