[Accessibility] Composer: Toggle Attach Menu with keyboard (#1783)

This commit is contained in:
Alexander Zinchuk 2022-03-25 13:14:55 +01:00
parent b2ad6a0ae4
commit 395786e0f9

View File

@ -35,6 +35,14 @@ const AttachMenu: FC<OwnProps> = ({
}
}, [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<OwnProps> = ({
className={isAttachMenuOpen ? 'AttachMenu--button activated' : 'AttachMenu--button'}
round
color="translucent"
onActivate={openAttachMenu}
onActivate={handleToggleAttachMenu}
ariaLabel="Add an attachment"
ariaControls="attach-menu-controls"
hasPopup