mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-07 20:44:05 +09:00
close the menu when input doesn't match but user hits enter
This commit is contained in:
1 parent
f7a647abb4
commit
c76e807989
1 file changed
+6
-2
+6
-2
@@ -188,14 +188,18 @@ const useKeyDown =
|
||||
onChange,
|
||||
onChangeComplete,
|
||||
onKeyDown,
|
||||
closeMenu,
|
||||
}: {
|
||||
value: StyleValue;
|
||||
onChange: (value: StyleValue) => void;
|
||||
onChangeComplete: (value: StyleValue) => void;
|
||||
onKeyDown: KeyboardEventHandler<HTMLInputElement>;
|
||||
closeMenu: () => void;
|
||||
}) =>
|
||||
(event: KeyboardEvent<HTMLInputElement>) => {
|
||||
onKeyDown(event);
|
||||
if (event.key === "Enter") {
|
||||
closeMenu();
|
||||
onChangeComplete(value);
|
||||
}
|
||||
if (
|
||||
@@ -207,8 +211,6 @@ const useKeyDown =
|
||||
value: calcNumberChange(value.value, event),
|
||||
});
|
||||
}
|
||||
|
||||
onKeyDown(event);
|
||||
};
|
||||
|
||||
type CssValueInputProps = {
|
||||
@@ -268,6 +270,7 @@ export const CssValueInput = ({
|
||||
getMenuProps,
|
||||
getItemProps,
|
||||
isOpen,
|
||||
closeMenu,
|
||||
} = useCombobox<StyleValue>({
|
||||
items: keywords,
|
||||
value,
|
||||
@@ -305,6 +308,7 @@ export const CssValueInput = ({
|
||||
onChange,
|
||||
onChangeComplete,
|
||||
onKeyDown: inputProps.onKeyDown,
|
||||
closeMenu,
|
||||
});
|
||||
|
||||
const suffix =
|
||||
|
||||
Reference in new issue
Block a user