mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-29 13:41:51 +02:00
A bunch of fixes
This commit is contained in:
@@ -101,6 +101,11 @@ export const Dropdown = forwardRef<DropdownRef, DropdownProps>(function Dropdown
|
||||
setDefaultSelectedIndex(undefined);
|
||||
}, [setIsOpen]);
|
||||
|
||||
const openDropdown = useCallback(() => {
|
||||
setIsOpen((o) => !o);
|
||||
setItems(typeof itemsGetter === 'function' ? itemsGetter() : itemsGetter);
|
||||
}, [itemsGetter, setIsOpen]);
|
||||
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => ({
|
||||
@@ -111,18 +116,18 @@ export const Dropdown = forwardRef<DropdownRef, DropdownProps>(function Dropdown
|
||||
else this.close();
|
||||
},
|
||||
open() {
|
||||
setIsOpen(true);
|
||||
openDropdown();
|
||||
},
|
||||
close() {
|
||||
handleClose();
|
||||
},
|
||||
}),
|
||||
[handleClose, isOpen, setIsOpen],
|
||||
[handleClose, isOpen, openDropdown],
|
||||
);
|
||||
|
||||
useHotKey(hotKeyAction ?? null, () => {
|
||||
setDefaultSelectedIndex(0);
|
||||
setIsOpen(true);
|
||||
openDropdown();
|
||||
});
|
||||
|
||||
const child = useMemo(() => {
|
||||
@@ -138,12 +143,11 @@ export const Dropdown = forwardRef<DropdownRef, DropdownProps>(function Dropdown
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setDefaultSelectedIndex(undefined);
|
||||
setIsOpen((o) => !o);
|
||||
setItems(typeof itemsGetter === 'function' ? itemsGetter() : itemsGetter);
|
||||
openDropdown();
|
||||
}),
|
||||
};
|
||||
return cloneElement(existingChild, props);
|
||||
}, [children, itemsGetter, setIsOpen]);
|
||||
}, [children, openDropdown]);
|
||||
|
||||
useEffect(() => {
|
||||
buttonRef.current?.setAttribute('aria-expanded', isOpen.toString());
|
||||
|
||||
@@ -563,6 +563,5 @@ function getCachedEditorState(doc: string, stateKey: string | null) {
|
||||
if (state == null) return null;
|
||||
if (state.doc.toString() !== doc) return null;
|
||||
|
||||
console.log('CACHED STATE', stateKey, state);
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user