Skip to content

Commit

Permalink
fix: close mobile TTS menu when page is resized or click outside menu
Browse files Browse the repository at this point in the history
  • Loading branch information
silvaezequias committed Jun 10, 2023
1 parent 486302c commit 417af9c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pages/interface/components/TextToSpeechControl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,20 @@ function MobileControls(props = {}) {
setSpeed(value / 10);
}

function closeDropdown() {
setDropdownIsOpen(false);
}

useEffect(() => {
window.addEventListener('resize', closeDropdown);
}, []);

return (
<Box sx={{ display: ['block', 'none'] }}>
<AnchoredOverlay
open={dropdownisOpen}
onClose={closeDropdown}
onOpen={() => setDropdownIsOpen(true)}
renderAnchor={(anchorProps) => (
<ButtonGroup
{...anchorProps}
Expand All @@ -179,8 +190,7 @@ function MobileControls(props = {}) {
</Button>
<IconButton size="small" variant="default" title="Conteúdo transformado em áudio" icon={MdHeadphones} />
</ButtonGroup>
)}
open={dropdownisOpen}>
)}>
<Box
sx={{
display: 'flex',
Expand Down

0 comments on commit 417af9c

Please sign in to comment.