From 76870c6a3780323d364da9b9c52502ab4c979378 Mon Sep 17 00:00:00 2001 From: Ng Yik Phang Date: Mon, 25 Jun 2018 13:10:06 +0800 Subject: [PATCH] Prevent page from scrolling to top when clicking languages button (#802) --- lib/core/nav/HeaderNav.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/core/nav/HeaderNav.js b/lib/core/nav/HeaderNav.js index 97bf6187e4aa..2285ec3cf964 100644 --- a/lib/core/nav/HeaderNav.js +++ b/lib/core/nav/HeaderNav.js @@ -101,8 +101,10 @@ class LanguageDropDown extends React.Component { __html: ` const languagesMenuItem = document.getElementById("languages-menu"); const languagesDropDown = document.getElementById("languages-dropdown"); - languagesMenuItem.addEventListener("click", function(){ - if(languagesDropDown.className == "hide") { + languagesMenuItem.addEventListener("click", function(event) { + event.preventDefault(); + + if (languagesDropDown.className == "hide") { languagesDropDown.className = "visible"; } else { languagesDropDown.className = "hide";