From 409a200ebcc0907f5ecb80a0862bd6efac79ed55 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:54:07 +1100 Subject: [PATCH] Fix URL prefix re-inserted when redirecting settings page (#4650) --- ui/v2.5/src/components/Settings/Settings.tsx | 33 ++++++++++---------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/ui/v2.5/src/components/Settings/Settings.tsx b/ui/v2.5/src/components/Settings/Settings.tsx index 182de71c7..4c2b02455 100644 --- a/ui/v2.5/src/components/Settings/Settings.tsx +++ b/ui/v2.5/src/components/Settings/Settings.tsx @@ -1,6 +1,6 @@ import React from "react"; import { Tab, Nav, Row, Col, Form } from "react-bootstrap"; -import { Redirect } from "react-router-dom"; +import { Redirect, useLocation } from "react-router-dom"; import { LinkContainer } from "react-router-bootstrap"; import { FormattedMessage } from "react-intl"; import { Helmet } from "react-helmet"; @@ -41,24 +41,11 @@ function isTabKey(tab: string | null): tab is TabKey { return validTabs.includes(tab as TabKey); } -const SettingTabs: React.FC = () => { - const tab = new URLSearchParams(location.search).get("tab"); - +const SettingTabs: React.FC<{ tab: TabKey }> = ({ tab }) => { const { advancedMode, setAdvancedMode } = useSettings(); const titleProps = useTitleProps({ id: "settings" }); - if (!isTabKey(tab)) { - return ( - - ); - } - return ( @@ -215,9 +202,23 @@ const SettingTabs: React.FC = () => { }; export const Settings: React.FC = () => { + const location = useLocation(); + const tab = new URLSearchParams(location.search).get("tab"); + + if (!isTabKey(tab)) { + return ( + + ); + } + return ( - + ); };