Skip to content

Commit

Permalink
Fixed navigation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sallaa committed Jun 28, 2024
1 parent 1c33562 commit bd47498
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/PopUp/PopUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const PopUp = () => {
variant="outlined"
color="primary"
fullWidth={true}
onClick={() => window.open("/popup.html#/app/tools/all")}
onClick={() => window.open("/popup.html#/app/tools")}
>
{keyword("open_website")}
</Button>
Expand Down
30 changes: 19 additions & 11 deletions src/components/SideMenu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,28 @@ const SideMenu = ({ tools, setOpenAlert }) => {
useEffect(() => {
//Set the redux state if the tool was opened from URL
const pathArr = window.location.href.split("/");
const path = pathArr[pathArr.length - 1].split("?")[0];

const lastNonEmptyPath = pathArr[pathArr.length - 1]
? pathArr[pathArr.length - 1]
: pathArr[pathArr.length - 2];

const path = lastNonEmptyPath.split("?")[0];

const toolWithPath = tools.find((tool) => tool.path === path);

if (toolWithPath) dispatch(selectTool(toolWithPath.titleKeyword));
if (toolWithPath) {
dispatch(selectTool(toolWithPath.titleKeyword));
console.log(toolWithPath);

//Now we open the drawer for the tool selected
const openDrawerForTool = listItems.find(
(i) => i.titleKeyword === toolWithPath.category,
).handleOpenCategoryDrawer;
//Now we open the drawer for the tool selected
const toolFromPath = listItems.find(
(i) => i.titleKeyword === toolWithPath.category,
);

openDrawerForTool();
if (toolFromPath) {
toolFromPath.handleOpenCategoryDrawer();
}
}
}, []);

const handleToolChange = (tool) => {
Expand Down Expand Up @@ -661,11 +672,8 @@ const SideMenu = ({ tools, setOpenAlert }) => {
alignItems="center"
justifyContent="center"
width="100%"
sx={{
...iconConditionalStyling(item),
}}
>
{item.icon}
<item.icon sx={iconConditionalStyling(item)} />
</Stack>
)}
</ListItemButton>
Expand Down

0 comments on commit bd47498

Please sign in to comment.