public function renderItems() {
		$items = [];
		foreach ($this->items as $i => $item) {
			if (isset($item['visible']) && !$item['visible']) {
				continue;
			}
			$items[] = $this->renderItem($item);
		}

		// Begin custom code
		$hasActive = false;
		foreach ($this->items as $i => $child) {
			if($this->isItemActive($child)) {
				$hasActive = true;
				break;
			}
		}

		if(!$hasActive) {
			Html::addCssClass($this->options, 'collapse');
		}
		// End custom code

		return Html::tag('ul', implode("\n", $items), $this->options);
	}
public function renderItems() {
		$items = [];
		foreach ($this->items as $i => $item) {
			if (isset($item['visible']) && !$item['visible']) {
				continue;
			}
			$items[] = $this->renderItem($item);
		}

		// Begin custom code
		$hasActive = false;
		foreach ($this->items as $i => $child) {
			if($this->isItemActive($child)) {
				$hasActive = true;
				break;
			}
		}

		if(!$hasActive) {
			Html::addCssClass($this->options, 'collapse');
		}
		// End custom code

		return Html::tag('ul', implode("\n", $items), $this->options);
	}
public function renderItems ( ) { $ items = [ ] ; foreach ( $ this -> items as $ i => $ item ) { if ( isset ( $ item [ 'visible' ] ) && ! $ item [ 'visible' ] ) { continue ; } $ items [ ] = $ this -> renderItem ( $ item ) ; } // Begin custom code $ hasActive = false ; foreach ( $ this -> items as $ i => $ child ) { if ( $ this -> isItemActive ( $ child ) ) { $ hasActive = true ; break ; } } if ( ! $ hasActive ) { Html :: addCssClass ( $ this -> options , 'collapse' ) ; } // End custom code return Html :: tag ( 'ul' , implode ( "\n" , $ items ) , $ this -> options ) ; }
Customized widget for MetisMenu navigation dropdowns to not flicker on page load
by precomputing if the menu should be open or not. Portions were added below to
add the 'collapse' css class if there is an item active within the submenu.
Customized widget for MetisMenu navigation dropdowns to not flicker on page load by precomputing if the menu should be open or not . Portions were added below to add the collapse css class if there is an item active within the submenu .