-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Automatically hide parent 'yii\bootstrap\Nav' section if all subitems are hidden #119
Conversation
…tion if all subitems are hidden
} | ||
|
||
$items = ArrayHelper::getValue($parentItem, 'items'); | ||
if (empty($items)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be:
$items = ArrayHelper::getValue($parentItem, 'items', []);
if ($items === []) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case testEmptyItems
is failing because we got null
and foreach
try to run on null
.
We can add additional check for null
but this is shorter.
@yiisoft/core-developers need additional review. |
@@ -202,6 +202,32 @@ public function renderItem($item) | |||
} | |||
|
|||
/** | |||
* Check if parent item is visible | |||
* @param array $parentItem | |||
* @return boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@since 2.0.7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe 2.0.6
? This extension has no version 2.0.6.
released yet and has own version history as I see. Or we need to write framework version here? Why in changelog last changes are written under 2.0.6
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, 2.0.6
, of course. Sorry, I've missed that we are in a separated repo
* @param array $parentItem | ||
* @return boolean | ||
*/ | ||
protected function isParentVisible($parentItem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name isParentVisible()
is not appropriate.
Should be isItemVisible()
, to be consistent with isItemActive()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more appropriate because only parent items (of the first level) checked like that, and item can be considered as parent even if it don't have any children.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name sounds like you are checking if item, which is parent to the given one, is chceked to be visible.
It is better to introduce |
Since now we have |
Maybe add this for now, if related issue is more difficult to implement. The amount of changes is small, so related issue can be implemented separately in the future, |
Adding protected method introduces new class API, which future change will cause BC break. |
@klimov-paul Could you summarize what's need to be fixed / changed in this case? |
Even if do not extend Actually, all we need to do is 'copy-paste' code from |
Closes #117