Menu: fix TypeScript error - #759
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Menu component’s TypeScript types to resolve an incompatibility stemming from inconsistent items typing between MenuSectionProps and MenuProps, aligning MenuProps.items to use MenuItemProps[].
Changes:
- Remove the generic type parameter from
MenuPropsand theMenucomponent signature. - Type
MenuPropsasReactAriaMenuProps<MenuItemProps>anditems?: MenuItemProps[]to matchMenuSectionProps.items.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ty2k
left a comment
There was a problem hiding this comment.
Good change, I think it's better to avoid the generic <T>.
On the itemsprop, I see right now it's required for MenuSectionProps but optional for MenuProps. If that's by design, can we add a comment to explain why? If it's not, can we use the same behaviour in both places?
Good spot — this was matching the structure from Select (where 6906096 makes |
This PR fixes a TypeScript error in the Menu component. Previously, there was an inconsistency in how the
itemsprop (used to pass an array of menu items) was typed in theMenuSectionPropsandMenuPropsinterfaces. InMenuPropsit was typed asitems?: T[], which caused an incompatibility error with theonActioncallback.With this change,
itemsis now typed consistently asitems: MenuItemProps[]in both contexts. This resolves the error, and is consistent with how we've approached this same functionality in Select.