Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/DropdownToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface UseDropdownToggleProps {
id: string;
ref: DropdownContextValue['setToggle'];
onClick: React.MouseEventHandler;
'aria-expanded': boolean;
'aria-expanded'?: boolean | null;
'aria-haspopup'?: true;
}

Expand Down Expand Up @@ -49,14 +49,16 @@ export function useDropdownToggle(): [
id,
ref: setToggle || noop,
onClick: handleClick,
'aria-expanded': !!show,
};

// This is maybe better down in an effect, but
// the component is going to update anyway when the menu element
// is set so might return new props.
if (menuElement && isRoleMenu(menuElement)) {
props['aria-haspopup'] = true;
props['aria-expanded'] = show || null;
} else {
props['aria-expanded'] = !!show;
}

return [props, { show, toggle }];
Expand Down