File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,16 @@ export type {MenuItemProps};
18
18
19
19
/**
20
20
* Recursively removes hidden items, including those nested in submenus
21
+ * Apply href to items that have a to or externalHref prop
21
22
*/
22
- function removeHiddenItems ( source : MenuItemProps [ ] ) : MenuItemProps [ ] {
23
+ function removeHiddenItemsAndSetHref ( source : MenuItemProps [ ] ) : MenuItemProps [ ] {
23
24
return source
24
25
. filter ( item => ! item . hidden )
25
26
. map ( item => ( {
26
27
...item ,
27
- ...( item . children ? { children : removeHiddenItems ( item . children ) } : { } ) ,
28
+ // react-aria uses the href prop on item state to determine if the item is a link
29
+ href : item . to ?? item . externalHref ,
30
+ ...( item . children ? { children : removeHiddenItemsAndSetHref ( item . children ) } : { } ) ,
28
31
} ) ) ;
29
32
}
30
33
@@ -221,17 +224,7 @@ function DropdownMenu({
221
224
) ;
222
225
}
223
226
224
- const activeItems = useMemo (
225
- ( ) =>
226
- removeHiddenItems ( items ) . map ( item => {
227
- return {
228
- ...item ,
229
- // react-aria uses the href prop on item state to determine if the item is a link
230
- href : item . to ?? item . externalHref ,
231
- } ;
232
- } ) ,
233
- [ items ]
234
- ) ;
227
+ const activeItems = useMemo ( ( ) => removeHiddenItemsAndSetHref ( items ) , [ items ] ) ;
235
228
const defaultDisabledKeys = useMemo ( ( ) => getDisabledKeys ( activeItems ) , [ activeItems ] ) ;
236
229
237
230
function renderMenu ( ) {
You can’t perform that action at this time.
0 commit comments