Skip to content

Commit

Permalink
chore(web): fix color field select (#737)
Browse files Browse the repository at this point in the history
Co-authored-by: nina992 <[email protected]>
  • Loading branch information
nina992 and nina992 authored Oct 12, 2023
1 parent 53aa05b commit ead2f52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions web/src/beta/components/fields/ColorField/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default ({ value, onChange }: Params) => {
const [rgba, setRgba] = useState<RGBA>(tinycolor(value).toRgb());
const [tempColor, setTempColor] = useState(colorState);
const [open, setOpen] = useState(false);

const wrapperRef = useRef<HTMLDivElement>(null);
const pickerRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -78,7 +79,9 @@ export default ({ value, onChange }: Params) => {

//events

const handleClick = useCallback(() => setOpen(!open), [open]);
const handleClick = useCallback(() => {
setOpen(!open);
}, [open]);

const handleKeyPress = useCallback(
(e: React.KeyboardEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -125,7 +128,7 @@ export default ({ value, onChange }: Params) => {
document.removeEventListener("mousedown", handleClickOutside);
document.removeEventListener("touchstart", handleClickOutside);
};
}, [handleClose]); // eslint-disable-line react-hooks/exhaustive-deps
}, []); // eslint-disable-line react-hooks/exhaustive-deps

return {
wrapperRef,
Expand Down
2 changes: 1 addition & 1 deletion web/src/beta/components/fields/ColorField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ColorField: React.FC<Props> = ({ name, description, value, onChange }) =>
return (
<Property name={name} description={description}>
<Wrapper ref={wrapperRef}>
<Popover.Provider open={open} placement="bottom-start" onOpenChange={handleClick}>
<Popover.Provider open={open} placement="bottom-start">
<Popover.Trigger asChild>
<InputWrapper ref={pickerRef}>
<Layers onClick={handleClick}>
Expand Down

0 comments on commit ead2f52

Please sign in to comment.