Skip to content

Commit

Permalink
update popper behavior on collapse
Browse files Browse the repository at this point in the history
  • Loading branch information
azouaoui-med committed Oct 13, 2022
1 parent 2c449e1 commit 5ce8b33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-pro-sidebar",
"version": "1.0.0-alpha.4",
"version": "1.0.0-alpha.5",
"description": "high level and customizable side navigation",
"main": "dist/index.js",
"module": "dist/index.es.js",
Expand Down
10 changes: 9 additions & 1 deletion src/components/SubMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const SubMenuFR: React.ForwardRefRenderFunction<HTMLLIElement, SubMenuPro

const handleSlideToggle = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>): void => {
onClick?.(event);
if (level === 0 && collapsed) setOpenWhenCollapsed(!openWhenCollapsed);
if (level === 0 && collapsed) setOpenWhenCollapsed((prevState) => !prevState);
else if (typeof openSubmenu === 'undefined') {
onOpenChange?.(!open);
setOpen(!open);
Expand All @@ -139,6 +139,14 @@ export const SubMenuFR: React.ForwardRefRenderFunction<HTMLLIElement, SubMenuPro
const instance = createPopper(anchorRef.current, SubMenuContentRef.current, {
placement: 'right',
strategy: 'fixed',
modifiers: [
{
name: 'offset',
options: {
offset: [0, 5],
},
},
],
});

setPopperInstance(instance);
Expand Down
3 changes: 1 addition & 2 deletions src/components/SubMenuContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ const StyledSubMenuContent = styled.div<SubMenuContentProps>`
${({ collapsed, firstLevel, openWhenCollapsed }) =>
collapsed && firstLevel
? `
margin-left: 5px!important;
margin-right: 5px!important;
padding-left: 0px;
width: 200px;
border-radius: 4px;
Expand Down

0 comments on commit 5ce8b33

Please sign in to comment.