pl-fe: a11y: set expanded state for dropdown buttons

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2025-06-28 14:44:12 +02:00
parent bfb526397a
commit 10bffa25ba

View File

@ -310,6 +310,7 @@ const DropdownMenu = (props: IDropdownMenu) => {
}, []);
useEffect(() => {
(refs.reference.current as HTMLButtonElement).setAttribute('aria-expanded', String(isOpen));
setTimeout(() => setIsDisplayed(isOpen), isOpen ? 0 : 150);
}, [isOpen]);
@ -324,6 +325,7 @@ const DropdownMenu = (props: IDropdownMenu) => {
onClick: handleClick,
onKeyPress: handleKeyPress,
ref: refs.setReference,
'aria-expanded': isOpen,
});
}, [children, !!items?.length, component]);