Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid definition item state in Bootstrap Nav class #183

Closed
yii-bot opened this issue Mar 10, 2017 · 2 comments
Closed

Invalid definition item state in Bootstrap Nav class #183

yii-bot opened this issue Mar 10, 2017 · 2 comments
Labels
status:to be verified Needs to be reproduced and validated.

Comments

@yii-bot
Copy link

yii-bot commented Mar 10, 2017

This issue has originally been reported by @poluda at yiisoft/yii2#13748.
Moved here by @samdark.


What steps will reproduce the problem?

$menuItem='posts';
echo Nav::widget([
'items' => [
['label' => 'Posts', 'url' => ['/posts/index'], 'active' => $menuItem == 'posts'],
['label' => 'Services', 'active' => $menuItem == 'services', 'items' => [
['label' => 'Petitions', 'url' => ['/petitions/index'], 'active' => false],
]],
],
'activateItems'=>true,
'encodeLabels' => false,
'options' => ['class' => 'nav navbar-nav'],
]);

What is the expected result?

The Item Petitions in dropdown must not have active css

What do you get instead?

dropdown item has css attribute class="active"

Additional info

original code:
protected function isChildActive($items, &$active)
{
foreach ($items as $i => $child) {
if (ArrayHelper::remove($items[$i], 'active', false) || $this->isItemActive($child)) {
Html::addCssClass($items[$i]['options'], 'active');
if ($this->activateParents) {
$active = true;
}
}
}
return $items;
}

Condition in line if (ArrayHelper::remove($items[$i], 'active', false) || $this->isItemActive($child)) {
is not correct. Problem is of using operator ||

| Yii version | 2.0
| PHP version | 5.6
| Operating system | windows 7

@machour
Copy link
Member

machour commented Jan 15, 2019

See also #209

@machour machour added status:to be verified Needs to be reproduced and validated. and removed ext:bootstrap labels Jan 15, 2019
@machour
Copy link
Member

machour commented Jan 15, 2019

Duplicate of #80

@machour machour marked this as a duplicate of #80 Jan 15, 2019
@machour machour closed this as completed Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated.
Projects
None yet
Development

No branches or pull requests

2 participants