@@ -428,6 +428,34 @@ export default function SettingsPage() {
428
428
} ,
429
429
] ;
430
430
431
+ const availableTabs = settingsTabs . filter ( ( tab ) => tab . condition ) ;
432
+
433
+ useEffect ( ( ) => {
434
+ const tabParam = router . query . tab as string ;
435
+ if ( tabParam ) {
436
+ const tabIndex = availableTabs . findIndex ( ( tab ) => tab . key === tabParam ) ;
437
+ if ( tabIndex !== - 1 ) {
438
+ setSelectedTabIndex ( tabIndex ) ;
439
+ }
440
+ }
441
+ } , [ router . query . tab , availableTabs ] ) ;
442
+
443
+ // Update URL when tab changes
444
+ const handleTabChange = ( index : number ) => {
445
+ const tabKey = availableTabs [ index ] ?. key ;
446
+ if ( tabKey ) {
447
+ void router . push (
448
+ {
449
+ pathname : router . pathname ,
450
+ query : { ...router . query , tab : tabKey } ,
451
+ } ,
452
+ undefined ,
453
+ { shallow : true } ,
454
+ ) ;
455
+ }
456
+ setSelectedTabIndex ( index ) ;
457
+ } ;
458
+
431
459
return (
432
460
< >
433
461
< div className = "flex h-full w-full flex-col overflow-hidden" >
@@ -445,14 +473,11 @@ export default function SettingsPage() {
445
473
446
474
< TabGroup
447
475
selectedIndex = { selectedTabIndex }
448
- onChange = { setSelectedTabIndex }
476
+ onChange = { handleTabChange }
449
477
>
450
478
< div className = "sm:hidden" >
451
479
{ /* Mobile dropdown */ }
452
- < Listbox
453
- value = { selectedTabIndex }
454
- onChange = { setSelectedTabIndex }
455
- >
480
+ < Listbox value = { selectedTabIndex } onChange = { handleTabChange } >
456
481
< div className = "relative" >
457
482
< ListboxButton className = "w-full appearance-none rounded-md bg-white py-2 pl-3 pr-8 text-left text-base text-gray-900 outline-1 -outline-offset-1 outline-gray-300 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 dark:bg-gray-900 dark:text-gray-100 dark:outline-white/10 dark:focus:outline-indigo-500" >
458
483
{ settingsTabs . filter ( ( tab ) => tab . condition ) [
0 commit comments