This commit is contained in:
parent
07de342fc2
commit
35fe877d58
32 changed files with 3822 additions and 200 deletions
|
|
@ -13,6 +13,7 @@ export function CompactDropdown({
|
|||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const rootRef = useRef(null);
|
||||
const internalPointerDownRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return undefined;
|
||||
|
|
@ -48,7 +49,14 @@ export function CompactDropdown({
|
|||
onMouseEnter={openOnHover ? () => setOpen(true) : undefined}
|
||||
onMouseLeave={closeOnMouseLeave ? close : undefined}
|
||||
onFocusCapture={openOnHover ? () => setOpen(true) : undefined}
|
||||
onPointerDownCapture={() => {
|
||||
internalPointerDownRef.current = true;
|
||||
window.setTimeout(() => {
|
||||
internalPointerDownRef.current = false;
|
||||
}, 0);
|
||||
}}
|
||||
onBlurCapture={(event) => {
|
||||
if (internalPointerDownRef.current) return;
|
||||
if (!event.currentTarget.contains(event.relatedTarget)) close();
|
||||
}}
|
||||
onMouseDown={preventMouseDown ? (event) => event.preventDefault() : undefined}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue