Unable to hide childItems in custom NavigationItem

I'm making a custom navigation setup and I want to conditionally hide an item from the childItems([...]), but it does not seem to work... this is a simple code to debug it faster, "nav-item-5" should be hidden
->navigation(function (NavigationBuilder $builder): NavigationBuilder {
return $builder
->items([
NavigationItem::make('nav-item-1')
->url('#'),
])
->groups([
NavigationGroup::make('group-1')
->items([
NavigationItem::make('nav-item-2')
->icon('heroicon-o-banknotes')
->url('#'),
NavigationItem::make('nav-item-3')
->icon('heroicon-o-banknotes')
->url('#')
->isActiveWhen(fn () => true)
->childItems([
NavigationItem::make('nav-item-4')
->url('#'),
NavigationItem::make('nav-item-5')
->hidden()
->url('#'),
]),
]),
]);
})
->navigation(function (NavigationBuilder $builder): NavigationBuilder {
return $builder
->items([
NavigationItem::make('nav-item-1')
->url('#'),
])
->groups([
NavigationGroup::make('group-1')
->items([
NavigationItem::make('nav-item-2')
->icon('heroicon-o-banknotes')
->url('#'),
NavigationItem::make('nav-item-3')
->icon('heroicon-o-banknotes')
->url('#')
->isActiveWhen(fn () => true)
->childItems([
NavigationItem::make('nav-item-4')
->url('#'),
NavigationItem::make('nav-item-5')
->hidden()
->url('#'),
]),
]),
]);
})
3 Replies
Bruno Silva
Bruno SilvaOP2mo ago
is this a normal behavior?
toeknee
toeknee2mo ago
what if you do ->visible(false) ? Does it still show?
Bruno Silva
Bruno SilvaOP2mo ago
yes
Want results from more Discord servers?
Add your server