Skip to content

Commit

Permalink
Replace the use of querySelector in favor of this.refs in ClayNavigat…
Browse files Browse the repository at this point in the history
…ionBar | Fixes liferay#812
  • Loading branch information
matuzalemsteles committed Apr 18, 2018
1 parent ae698da commit 8c8f9c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions packages/clay-navigation-bar/src/ClayNavigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ClayNavigationBar extends Component {
/**
* @inheritDoc
*/
// eslint-disable-next-line
sync_isTransitioning() {
if (this._isTransitioning && !this._visible) {
this._setCollapseHeight();
Expand Down Expand Up @@ -50,7 +49,7 @@ class ClayNavigationBar extends Component {
* @private
*/
_handleTransitionEnd(event) {
const element = this.element.querySelector('.navbar-collapse');
const element = this.refs.content;
if (
element == event.target &&
this._isTransitioning &&
Expand All @@ -70,23 +69,19 @@ class ClayNavigationBar extends Component {
* @private
*/
_removeCollapseHeight() {
const elementCollapse = this.element.querySelector('.navbar-collapse');
elementCollapse.style.removeProperty('height');
this.refs.content.style.removeProperty('height');
}

/**
* Sets the height css property on `.navbar-collapse`
* @private
*/
_setCollapseHeight() {
const elementCollapse = this.element.querySelector('.navbar-collapse');
const heightCollapse = elementCollapse.querySelector(
'.container-fluid'
).clientHeight;
const elementCollapse = this.refs.content;

elementCollapse.setAttribute(
'style',
`height: ${heightCollapse}px`
`height: ${elementCollapse.children[0].clientHeight}px`
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/clay-navigation-bar/src/ClayNavigationBar.soy
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
{/if}
{/let}

<div class="{$classes}">
<div class="{$classes}" ref="content">
<div class="container-fluid container-fluid-max-xl">
{if $items}
{call .navmenu}
Expand Down

0 comments on commit 8c8f9c1

Please sign in to comment.