Skip to content

Commit

Permalink
Force window.location refresh on nav and language links click
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Jan 25, 2021
1 parent c061778 commit 0d97a48
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/customizations/components/theme/Navigation/Navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class Navigation extends Component {
super(props);
this.toggleMobileMenu = this.toggleMobileMenu.bind(this);
this.closeMobileMenu = this.closeMobileMenu.bind(this);
this.onLinkClick = this.onLinkClick.bind(this);
this.state = {
isMobileMenuOpen: false,
activeIndex: -1,
Expand Down Expand Up @@ -154,6 +155,17 @@ class Navigation extends Component {
this.setState({ isMobileMenuOpen: false });
}

/**
* Click an internal link
* @method onLinkClick
* @returns {undefined}
*/
onLinkClick(evt, url) {
evt.preventDefault();
this.closeMobileMenu();
window.location = url;
}

/**
* Render method.
* @method render
Expand Down Expand Up @@ -218,7 +230,7 @@ class Navigation extends Component {
? item.url === `/${lang}`
: item.url === ''
}
onClick={this.closeMobileMenu}
onClick={(evt) => this.onLinkClick(evt, item.url || '/')}
>
{item.title}
</NavLink>
Expand All @@ -243,7 +255,10 @@ class Navigation extends Component {
<List.Content>
<List.Description>
<a
href={`https://www.eea.europa.eu/${language.code}`}
href={`/${language.code}`}
onClick={(evt) =>
this.onLinkClick(evt, `/${language.code}`)
}
>
{`${language.name} (${language.code})`}
</a>
Expand Down Expand Up @@ -273,7 +288,10 @@ class Navigation extends Component {
<List.Content>
<List.Description>
<a
href={`https://www.eea.europa.eu/${language.code}`}
href={`/${language.code}`}
onClick={(evt) =>
this.onLinkClick(evt, `/${language.code}`)
}
>
{`${language.name} (${language.code})`}
</a>
Expand Down

0 comments on commit 0d97a48

Please sign in to comment.