Auto close theme selector

This commit is contained in:
Neshura 2022-12-16 22:58:46 +01:00
parent 2ec2f70772
commit 44e446c483
No known key found for this signature in database
GPG key ID: ACDF5B6EBECF6B0A

View file

@ -45,9 +45,16 @@ export const StyleSelector = () => {
const [test, setTest] = useState(false); const [test, setTest] = useState(false);
function handleBlur(event:any) {
console.log(event)
if (!event.currentTarget.contains(event.relatedTarget)) {
setTest(false);
}
}
return ( return (
<ThemeDropDown> <ThemeDropDown onBlur={(event) => handleBlur(event)}>
<ThemeDropDownButton onClick={() => setTest(test => !test)}>{selectedTheme.themeName}</ThemeDropDownButton> <ThemeDropDownButton onClick={() => setTest(test => !test)}>{selectedTheme.themeName}</ThemeDropDownButton>
<ThemeDropDownOptions id="themesDropdown" show={test}> <ThemeDropDownOptions id="themesDropdown" show={test}>
{themes.map((theme) => ( {themes.map((theme) => (