diff --git a/src/components/ValidatorModal.js b/src/components/ValidatorModal.js
index a0609685..38b57a2a 100644
--- a/src/components/ValidatorModal.js
+++ b/src/components/ValidatorModal.js
@@ -19,24 +19,30 @@ import ValidatorGrants from './ValidatorGrants';
function ValidatorModal(props) {
const { redelegate, undelegate, validator, delegations, operators, network, validators, grants } = props
- const [selectedValidator, setSelectedValidator] = useState(!redelegate && validator);
- const [activeTab, setActiveTab] = useState();
const navigate = useNavigate()
const params = useParams();
+ const [selectedValidator, setSelectedValidator] = useState(!redelegate && validator);
+ const [activeTab, setActiveTab] = useState(params.section);
useEffect(() => {
if(params.network !== network.name) return
- if (props.show && selectedValidator && validator?.operator_address === selectedValidator.operator_address && params.validator !== selectedValidator.operator_address) {
- navigate(`/${network.name}/${selectedValidator.operator_address}`)
+ const shouldShow = props.show && selectedValidator && validator?.operator_address === selectedValidator.operator_address
+ const shouldChangeValidator = params.validator !== selectedValidator?.operator_address
+ const shouldChangeTab = activeTab === 'profile' ? !!params.section : params.section !== activeTab
+ const shouldChangeUrl = shouldShow && (shouldChangeValidator || shouldChangeTab)
+ if (shouldChangeUrl) {
+ navigate(`/${network.name}/${selectedValidator.operator_address}${activeTab === 'profile' ? '' : `/${activeTab}`}`)
} else if (params.validator && props.show === false) {
navigate(`/${network.name}`)
}
- }, [props.show, params.validator, selectedValidator])
+ }, [props.show, params.validator, params.section, activeTab, selectedValidator])
useEffect(() => {
if (props.activeTab && props.activeTab != activeTab) {
setActiveTab(props.activeTab)
+ } else if (params.section && params.section != activeTab) {
+ setActiveTab(params.section)
} else if (redelegate || undelegate) {
setActiveTab('delegate')
} else if (!activeTab) {
diff --git a/src/index.js b/src/index.js
index 2531b46b..9b6914ab 100644
--- a/src/index.js
+++ b/src/index.js
@@ -24,6 +24,7 @@ const app = (
} />
} />
} />
+ } />