You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
isSelected is set based on comparing index and selectionIndex. But if the descendant cannot be found and there is no selection the menu item is incorrectly marked as selected
letisSelected=index===selectionIndex&&!disabled;
On the next render this is fixed because the descendant can be found.
Expected behavior
On first render if a descendant cannot be found do not mark it as selected
Suggested solution(s)
Adding an additional check that the index is greater or equal to 0
I'm actually using menu-button in custom components. A not rendering the MenuPopover until isExpanded is true, cause I'm on React 18 and following the suggestions here
Your environment
Software
Name(s)
Version
Reach Package
menu-button
0.18.0
React
18.2.0
Browser
Firefox
113
Assistive tech
-
-
Node
16
npm/yarn
yarn
1.22.19
Operating System
macOS
13.3
The text was updated successfully, but these errors were encountered:
🐛 Bug report
Current Behavior
isSelected is set based on comparing
index
andselectionIndex
. But if the descendant cannot be found and there is no selection the menu item is incorrectly marked as selectedOn the next render this is fixed because the descendant can be found.
Expected behavior
On first render if a descendant cannot be found do not mark it as selected
Suggested solution(s)
Adding an additional check that the index is greater or equal to 0
Additional context
I'm actually using
menu-button
in custom components. A not rendering theMenuPopover
untilisExpanded
is true, cause I'm on React 18 and following the suggestions hereYour environment
The text was updated successfully, but these errors were encountered: