Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server side sidebar rendering #5993

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/volto/news/5993.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix server side sidebar rendering @sneridagh
42 changes: 24 additions & 18 deletions packages/volto/src/components/manage/Sidebar/SidebarPopup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const SidebarPopup = (props) => {
onClose();
};

const [isClient, setIsClient] = React.useState(false);
React.useEffect(() => {
setIsClient(true);
}, []);

React.useEffect(() => {
document.addEventListener('mousedown', handleClickOutside, false);
return () => {
Expand Down Expand Up @@ -48,24 +53,25 @@ const SidebarPopup = (props) => {
unmountOnExit
>
<>
{createPortal(
<aside
role="presentation"
onClick={(e) => {
e.stopPropagation();
}}
onKeyDown={(e) => {
e.stopPropagation();
}}
ref={asideElement}
key="sidebarpopup"
className="sidebar-container"
style={{ overflowY: 'auto' }}
>
{children}
</aside>,
document.body,
)}
{isClient &&
createPortal(
<aside
role="presentation"
onClick={(e) => {
e.stopPropagation();
}}
onKeyDown={(e) => {
e.stopPropagation();
}}
ref={asideElement}
key="sidebarpopup"
className="sidebar-container"
style={{ overflowY: 'auto' }}
>
{children}
</aside>,
document.body,
)}
</>
</CSSTransition>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,7 @@ exports[`sidebar popup is not rendered when the block is not selected 1`] = `
timeout={500}
unmountOnExit={true}
>
<React.Fragment>
Object {
"$$typeof": Symbol(react.portal),
"children": <aside
className="sidebar-container"
onClick={[Function]}
onKeyDown={[Function]}
role="presentation"
style={
Object {
"overflowY": "auto",
}
}
>
<p>
Tested, but you shouldn't see this in the snapshot!
</p>
</aside>,
"containerInfo": <body />,
"implementation": null,
"key": null,
}
</React.Fragment>
<React.Fragment />
</CSSTransition>
</React.Fragment>
`;
Expand All @@ -43,29 +21,7 @@ exports[`sidebar popup is rendered when the block is selected 1`] = `
timeout={500}
unmountOnExit={true}
>
<React.Fragment>
Object {
"$$typeof": Symbol(react.portal),
"children": <aside
className="sidebar-container"
onClick={[Function]}
onKeyDown={[Function]}
role="presentation"
style={
Object {
"overflowY": "auto",
}
}
>
<p>
Tested!
</p>
</aside>,
"containerInfo": <body />,
"implementation": null,
"key": null,
}
</React.Fragment>
<React.Fragment />
</CSSTransition>
</React.Fragment>
`;
Loading