Skip to content

Commit 2a7f5b5

Browse files
committed
#22071: MTF test fix.
1 parent 3d3273c commit 2a7f5b5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

app/code/Magento/Theme/Block/Html/Topmenu.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,15 @@ public function getHtml($outermostClass = '', $childrenWrapClass = '', $limit =
9292
$this->getMenu()->setOutermostClass($outermostClass);
9393
$this->getMenu()->setChildrenWrapClass($childrenWrapClass);
9494

95-
$transportObject = new DataObject([
96-
'html' => $this->_getHtml($this->getMenu(), $childrenWrapClass, $limit)
97-
]);
95+
$transportObject = new DataObject(
96+
[
97+
'html' => $this->_getHtml(
98+
$this->getMenu(),
99+
$childrenWrapClass,
100+
$limit
101+
)
102+
]
103+
);
98104

99105
$this->_eventManager->dispatch(
100106
'page_block_html_topmenu_gethtml_after',
@@ -211,8 +217,8 @@ protected function _getHtml(
211217
$html = '';
212218

213219
$children = $menuTree->getChildren();
214-
$this->removeChildrenWithoutActiveParent($children);
215220
$childLevel = $this->getChildLevel($menuTree->getLevel());
221+
$this->removeChildrenWithoutActiveParent($children, $childLevel);
216222

217223
$counter = 1;
218224
$childrenCount = $children->count();
@@ -387,14 +393,14 @@ public function getMenu()
387393
* Remove children from collection when the parent is not active
388394
*
389395
* @param Collection $children
390-
*
396+
* @param int $childLevel
391397
* @return void
392398
*/
393-
private function removeChildrenWithoutActiveParent(Collection $children)
399+
private function removeChildrenWithoutActiveParent(Collection $children, int $childLevel): void
394400
{
395401
/** @var Node $child */
396402
foreach ($children as $child) {
397-
if ($child->getData('is_parent_active') === false) {
403+
if ($childLevel === 0 && $child->getData('is_parent_active') === false) {
398404
$children->delete($child);
399405
}
400406
}
@@ -407,7 +413,7 @@ private function removeChildrenWithoutActiveParent(Collection $children)
407413
*
408414
* @return int
409415
*/
410-
private function getChildLevel($parentLevel)
416+
private function getChildLevel($parentLevel): int
411417
{
412418
return $parentLevel === null ? 0 : $parentLevel + 1;
413419
}

0 commit comments

Comments
 (0)