You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by sh...@apache.org on 2025/07/22 07:50:29 UTC
(answer-website) branch fix-nav created (now 485e258e7)
This is an automated email from the ASF dual-hosted git repository.
shuai pushed a change to branch fix-nav
in repository https://gitbox.apache.org/repos/asf/answer-website.git
at 485e258e7 fix: submenu in the mobile navigation fails to expand properly #334
This branch includes the following new commits:
new 485e258e7 fix: submenu in the mobile navigation fails to expand properly #334
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(answer-website) 01/01: fix: submenu in the mobile navigation fails to expand properly #334
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuai pushed a commit to branch fix-nav
in repository https://gitbox.apache.org/repos/asf/answer-website.git
commit 485e258e7fb261839a49a663905ba6e4fb322220
Author: shuai <li...@sifou.com>
AuthorDate: Tue Jul 22 15:50:05 2025 +0800
fix: submenu in the mobile navigation fails to expand properly #334
---
src/css/custom.scss | 4 ++--
src/theme/NavbarItem/NavbarNavLink.tsx | 21 +++++++++++++--------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/css/custom.scss b/src/css/custom.scss
index bc9f260f8..8a7027dcd 100644
--- a/src/css/custom.scss
+++ b/src/css/custom.scss
@@ -58,12 +58,12 @@ $primary: #0033ff;
opacity: 0.75;
}
-.navbar__link.bi-translate {
+.bi-translate {
svg {
display: none;
}
}
-.navbar__link.bi::before {
+.bi-translate::before {
font-size: 24px;
margin-right: 0.25rem;;
}
diff --git a/src/theme/NavbarItem/NavbarNavLink.tsx b/src/theme/NavbarItem/NavbarNavLink.tsx
index 70d0ba0c9..fc9b920dc 100644
--- a/src/theme/NavbarItem/NavbarNavLink.tsx
+++ b/src/theme/NavbarItem/NavbarNavLink.tsx
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
-import React from 'react';
+import React, { useEffect } from 'react';
import Link from '@docusaurus/Link';
import useBaseUrl from '@docusaurus/useBaseUrl';
import isInternalUrl from '@docusaurus/isInternalUrl';
@@ -40,11 +40,18 @@ export default function NavbarNavLink({
const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
const isExternalLink = label && href && !isInternalUrl(href);
- const clickLink = (e) => {
- if (e.target?.lang) {
- localStorage.setItem('_lang_user_', e.target.lang);
- }
- }
+ useEffect(() => {
+ const handleClick = (event) => {
+ if (event.target.tagName === 'A' && event.target.lang) {
+ localStorage.setItem('_lang_user_', event.target.lang);
+ }
+ };
+ document.addEventListener('click', handleClick);
+
+ return () => {
+ document.removeEventListener('click', handleClick);
+ };
+ }, [])
// Link content is set through html XOR label
const linkContentProps = html
@@ -68,7 +75,6 @@ export default function NavbarNavLink({
href={prependBaseUrlToHref ? normalizedHref : href}
{...props}
{...linkContentProps}
- onClick={clickLink}
/>
);
}
@@ -85,7 +91,6 @@ export default function NavbarNavLink({
})}
{...props}
{...linkContentProps}
- onClick={clickLink}
/>
);
}