Skip to content

Commit

Permalink
Fixed a bug where some tools would still be selected after leaving them
Browse files Browse the repository at this point in the history
  • Loading branch information
Sallaa committed Jul 1, 2024
1 parent d3a2c01 commit 27ebbcc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/components/TopMenu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useDispatch, useSelector } from "react-redux";
import { i18nLoadNamespace } from "../Shared/Languages/i18nLoadNamespace";
import { selectTopMenuItem } from "../../redux/reducers/navReducer";
import { toolsHome } from "../../constants/tools";
import { resetToolSelected } from "../../redux/reducers/tools/toolReducer";

const TopMenu = ({ topMenuItems }) => {
const classes = useMyStyles();
Expand All @@ -28,10 +29,8 @@ const TopMenu = ({ topMenuItems }) => {
const handleTopMenuChange = (event, newValue) => {
dispatch(selectTopMenuItem(newValue));

if (newValue === "tools") {
navigate("/app/" + toolsHome.path);
} else {
navigate("/app/" + "assistant");
if (newValue !== toolsHome.titleKeyword) {
dispatch(resetToolSelected());
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/redux/reducers/tools/toolReducer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const toolSlice = createSlice({
selectTool(state, action) {
state.toolName = action.payload;
},
cleanTool() {
resetToolSelected() {
return initialState;
},
},
});

export const { selectTool, cleanTool } = toolSlice.actions;
export const { selectTool, resetToolSelected } = toolSlice.actions;
const toolReducer = toolSlice.reducer;

export default toolReducer;

0 comments on commit 27ebbcc

Please sign in to comment.