Web:Added content change in submenu when clicking the back button in the browser.
This commit is contained in:
parent
2e004c1fc1
commit
0d24c1a2ab
@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback } from "react";
|
import React, { useState, useCallback, useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import styled, { css } from "styled-components";
|
import styled, { css } from "styled-components";
|
||||||
import { withRouter } from "react-router";
|
import { withRouter } from "react-router";
|
||||||
@ -44,6 +44,15 @@ const SectionBodyContent = ({ isErrorSettings, history, user }) => {
|
|||||||
content: <GeneralSettings t={t} />,
|
content: <GeneralSettings t={t} />,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const defaultStartSelect =
|
||||||
|
setting === "common" ? commonSettings : adminSettings;
|
||||||
|
|
||||||
|
const [startSelect, setStartSelect] = useState(defaultStartSelect);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setStartSelect(defaultStartSelect);
|
||||||
|
}, [setting]);
|
||||||
|
|
||||||
const data = [adminSettings, commonSettings];
|
const data = [adminSettings, commonSettings];
|
||||||
|
|
||||||
const onSelect = useCallback(
|
const onSelect = useCallback(
|
||||||
@ -76,11 +85,7 @@ const SectionBodyContent = ({ isErrorSettings, history, user }) => {
|
|||||||
showAdminSettings={showAdminSettings}
|
showAdminSettings={showAdminSettings}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Submenu
|
<Submenu data={data} startSelect={startSelect} onSelect={onSelect} />
|
||||||
data={data}
|
|
||||||
startSelect={setting === "common" ? commonSettings : adminSettings}
|
|
||||||
onSelect={onSelect}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</StyledContainer>
|
</StyledContainer>
|
||||||
);
|
);
|
||||||
|
@ -22,9 +22,13 @@ const Submenu = (props) => {
|
|||||||
} = props;
|
} = props;
|
||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
|
|
||||||
const [currentItem, setCurrentItem] = useState(
|
const defaultCurrentItem = data[startSelect] || startSelect || null;
|
||||||
data[startSelect] || startSelect || null
|
|
||||||
);
|
const [currentItem, setCurrentItem] = useState(defaultCurrentItem);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setCurrentItem(defaultCurrentItem);
|
||||||
|
}, [startSelect.id]);
|
||||||
|
|
||||||
const submenuItemsRef = useRef();
|
const submenuItemsRef = useRef();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user