So i have this problem when i click navbar it dosent expand but when i go to a not found (#404) Page it works
and when i inspect the aria-expanded is set to true
but when i go to my main page i inspect the aria-expanded is set to false
this is my code:
NavBar::begin([
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
$menuItems = [
['label' => 'Product', 'url' => ['product/index']],
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Register', 'url' => ['/site/register']];
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
if(yii::$app->user->can('admin')){
$menuItems[] = ['label' => 'Users', 'url' => ['new-user/index']];
$menuItems[] = ['label' => 'Category', 'url' => ['category/index']];
}
$menuItems[] =
[
'encode' => false,
'label' => ('app'),
'items' =>
[['encode' => false, 'label' => ('app'),],
['label' => (Yii::$app->user->identity->username), 'options' => ['style' => 'margin-left: 93px; font-size: 15px; color: white; font-weight: bold; margin-top: 3px;'] ],
['label' => (Yii::$app->user->identity->email), 'options' => ['style' => 'margin-left: 38px; font-size: 15px; color: white; margin-top: -5px;'] ],
['encode' => false,'label' => Html::submitButton('<i class="far fa-user"></i>My Profile', ['style' => 'background-color: transparent; border: none; font-size: 15px;']), 'url' => ['/site/logout'],],
['encode' => false,'label' => Html::submitButton('<i class="far fa-comment-alt"></i>Messages', ['style' => 'background-color: transparent; border: none; font-size: 15px;']), 'url' => ['/site/logout'],],
['encode' => false,'label' => Html::submitButton('<i class="far fa-calendar-check"></i>Activity', ['style' => 'background-color: transparent; border: none; font-size: 15px;']), 'url' => ['/site/logout'],],
['encode' => false,'label' => Html::submitButton('<i class="far fa-question-circle"></i>FAQ', ['style' => 'background-color: transparent; border: none; font-size: 15px;']), 'url' => ['/site/logout'],],
['encode' => false,'label' => Html::submitButton('<i class="fas fa-sign-out-alt"></i>Sign Out', ['style' => 'background-color: transparent; border: none; font-size: 15px; color: white;'], ),
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post', 'style' => 'font-size: 15px; color: black;']],
]
];
}
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
NavBar::end();
I would appreciate if you would give me an answer and explain it to me why is it like that.
Thank you in advance !!!