diff --git a/src/components/middle/composer/AttachMenu.tsx b/src/components/middle/composer/AttachMenu.tsx index 14e328ca..648d42ba 100644 --- a/src/components/middle/composer/AttachMenu.tsx +++ b/src/components/middle/composer/AttachMenu.tsx @@ -35,6 +35,14 @@ const AttachMenu: FC = ({ } }, [isAttachMenuOpen, markMouseInside]); + const handleToggleAttachMenu = useCallback(() => { + if (isAttachMenuOpen) { + closeAttachMenu(); + } else { + openAttachMenu(); + } + }, [isAttachMenuOpen, openAttachMenu, closeAttachMenu]); + const handleFileSelect = useCallback((e: Event, isQuick: boolean) => { const { files } = e.target as HTMLInputElement; @@ -67,7 +75,7 @@ const AttachMenu: FC = ({ className={isAttachMenuOpen ? 'AttachMenu--button activated' : 'AttachMenu--button'} round color="translucent" - onActivate={openAttachMenu} + onActivate={handleToggleAttachMenu} ariaLabel="Add an attachment" ariaControls="attach-menu-controls" hasPopup