original_string: 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);
  	}
code: 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);
  	}
code_tokens: 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 ) ; }
docstring: 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.
docstring_tokens: 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 .