@@ -86,14 +86,29 @@ const MobileLanguagePicker = ({ onLanguageChange }) => {
86
86
} ;
87
87
88
88
// Handle language selection
89
- const handleLanguageSelect = ( locale , href ) => {
89
+ const handleLanguageSelect = async ( locale , href ) => {
90
90
setIsOpen ( false ) ;
91
91
92
92
// Notify parent component about language change if callback provided
93
93
if ( onLanguageChange ) {
94
94
onLanguageChange ( locale , href ) ;
95
- } else {
96
- // Fallback navigation if no callback
95
+ }
96
+
97
+ // Try client-side navigation first
98
+ try {
99
+ // Use history.push for client-side navigation
100
+ const { history } = await import ( '@docusaurus/router' ) ;
101
+ history . push ( href ) ;
102
+
103
+ // Force a small delay to allow React to update, then trigger a re-render
104
+ setTimeout ( ( ) => {
105
+ // Force re-render by updating a state or triggering a window event
106
+ window . dispatchEvent ( new Event ( 'languageChanged' ) ) ;
107
+ } , 100 ) ;
108
+
109
+ } catch ( error ) {
110
+ // Fallback to full page reload if client-side navigation fails
111
+ console . warn ( 'Client-side navigation failed, falling back to full reload:' , error ) ;
97
112
window . location . href = href ;
98
113
}
99
114
} ;
@@ -144,9 +159,9 @@ const MobileLanguagePicker = ({ onLanguageChange }) => {
144
159
// Handle docs root paths specifically
145
160
if ( currentPath === '/docs' || currentPath === '/docs/' ) {
146
161
if ( locale === i18n . defaultLocale || locale === 'en' ) {
147
- href = '/docs/ ' ;
162
+ href = '/docs' ;
148
163
} else {
149
- href = `/docs/${ locale } / ` ;
164
+ href = `/docs/${ locale } ` ;
150
165
}
151
166
} else {
152
167
// Remove existing locale from docs path if present
0 commit comments