DropdownMenu fix

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-08-16 16:56:17 +02:00
parent 55b5b50216
commit 639299ee1c
2 changed files with 1 additions and 35 deletions

View file

@ -312,7 +312,7 @@ const DropdownMenu = (props: IDropdownMenu) => {
<li className='p-2 px-3'>
<button
className='flex w-full appearance-none place-content-center items-center justify-center rounded-full border border-gray-700 bg-transparent p-2 text-sm font-medium text-gray-700 transition-all hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-offset-2 dark:border-gray-500 dark:text-gray-500'
onClick={onClose}
onClick={handleClose}
>
<FormattedMessage id='lightbox.close' defaultMessage='Close' />
</button>

View file

@ -52,39 +52,6 @@ const getLanguageDropdown = (composeId: string): React.FC<ILanguageDropdown> =>
textMap,
} = useCompose(composeId);
const handleOptionKeyDown: React.KeyboardEventHandler = e => {
const value = e.currentTarget.getAttribute('data-index');
const index = results.findIndex(([key]) => key === value);
let element: ChildNode | null | undefined = null;
switch (e.key) {
case 'Escape':
handleClose();
break;
case 'Enter':
handleOptionClick(e);
break;
case 'ArrowDown':
element = node.current?.childNodes[index + 1] || node.current?.firstChild;
break;
case 'ArrowUp':
element = node.current?.childNodes[index - 1] || node.current?.lastChild;
break;
case 'Home':
element = node.current?.firstChild;
break;
case 'End':
element = node.current?.lastChild;
break;
}
if (element) {
(element as HTMLElement).focus();
e.preventDefault();
e.stopPropagation();
}
};
const handleOptionClick: React.EventHandler<any> = (e: MouseEvent | KeyboardEvent) => {
const value = (e.currentTarget as HTMLElement)?.getAttribute('data-index') as Language;
@ -207,7 +174,6 @@ const getLanguageDropdown = (composeId: string): React.FC<ILanguageDropdown> =>
tabIndex={0}
key={code}
data-index={code}
onKeyDown={handleOptionKeyDown}
onClick={handleOptionClick}
className={clsx(
'flex w-full gap-2 p-2.5 text-left text-sm text-gray-700 dark:text-gray-400',