Skip to content

Commit 9485b2c

Browse files
committed
fix bug where panel data kept from last run
1 parent 7250c34 commit 9485b2c

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/MegaMenuBuilder.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class MegaMenuBuilder {
7070
*/
7171
public function build($item, int $cols) {
7272
$columns_data = [];
73+
// Reset variables on build.
74+
$this->split = FALSE;
75+
$this->splitId = '';
76+
$this->splitAmount = 0;
77+
$this->panelData = [];
78+
$this->total = 0;
7379

7480
// If there are no child menu items then exit. It is only 1 menu item and we
7581
// can build a mega menu panel from 1 menu item.
@@ -172,10 +178,6 @@ protected function checkSplit(array $items): bool {
172178

173179
// Only columns bigger then 2 can have a split column.
174180
if ($this->cols <= 2) {
175-
$this->split = FALSE;
176-
$this->splitId = '';
177-
$this->splitAmount = 0;
178-
179181
return FALSE;
180182
}
181183

@@ -186,10 +188,6 @@ protected function checkSplit(array $items): bool {
186188
$after = array_key_last($items) != $split_id;
187189
// Has items before and after then don't split.
188190
if ($before & $after) {
189-
$this->split = FALSE;
190-
$this->splitId = '';
191-
$this->splitAmount = 0;
192-
193191
return FALSE;
194192
}
195193
}

0 commit comments

Comments
 (0)