File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
packages/plus/src/components/Navigation/components Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @ultraviolet/plus " : patch
3
+ ---
4
+
5
+ ` Navigation ` : isActive should work when the Item is wrapped in a Link/NavLink (React rooter)
Original file line number Diff line number Diff line change @@ -116,7 +116,8 @@ const StyledMenuItem = styled(Menu.Item, {
116
116
}
117
117
118
118
${ StyledBadge } {
119
- opacity: ${ ( { isPinnable, pinnedFeature } ) => ( isPinnable && pinnedFeature ? 0 : 1 ) } ;
119
+ opacity: ${ ( { isPinnable, pinnedFeature } ) =>
120
+ isPinnable && pinnedFeature ? 0 : 1 } ;
120
121
}
121
122
}
122
123
`
@@ -265,6 +266,10 @@ const ContainerCategoryIcon = styled(Stack)`
265
266
266
267
type ItemType = 'default' | 'pinned' | 'pinnedGroup'
267
268
269
+ type LinkProps = {
270
+ to : string
271
+ children ?: { props : ItemProps }
272
+ }
268
273
type ItemProps = {
269
274
children ?: ReactNode
270
275
/**
@@ -437,9 +442,18 @@ export const Item = memo(
437
442
if ( ! children ) return false
438
443
439
444
return (
440
- Children . map ( children , child =>
441
- isValidElement < ItemProps > ( child ) ? child . props ?. active : false ,
442
- ) as boolean [ ]
445
+ Children . map ( children , child => {
446
+ if ( isValidElement < ItemProps | LinkProps > ( child ) ) {
447
+ // In case the Item is wrapped in a link
448
+ if ( 'to' in child . props ) {
449
+ return child . props . children ?. props . active
450
+ }
451
+
452
+ return child . props . active
453
+ }
454
+
455
+ return null
456
+ } ) as boolean [ ]
443
457
) . includes ( true )
444
458
} , [ children ] )
445
459
You can’t perform that action at this time.
0 commit comments