Skip to content

Commit

Permalink
Fixed sidebar popup disappearing
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Mar 24, 2021
1 parent 38721c6 commit a5c0c68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions src/StyleWrapper/StyleWrapperEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,19 @@ import clearSVG from '@plone/volto/icons/clear.svg';
const StyleWrapperEdit = (props) => {
const { selected, onChangeValue, data, isVisible, setIsVisible } = props;

const nodeRef = React.useRef();
const schema = React.useMemo(() => StyleSchema(), []);

const closeSidebar = React.useCallback(
(e) => {
let containClick = false;
let clickInSidebars = false;
const sidebars =
document.querySelectorAll('aside.sidebar-container') || [];
sidebars.forEach((sidebar) => {
if (doesNodeContainClick(sidebar, e) && !containClick) {
containClick = true;
if (doesNodeContainClick(sidebar, e) && !clickInSidebars) {
clickInSidebars = true;
}
});
if (
isVisible &&
!containClick &&
!doesNodeContainClick(nodeRef.current, e)
) {
if (isVisible && !clickInSidebars) {
setIsVisible(false);
}
},
Expand All @@ -41,7 +36,7 @@ const StyleWrapperEdit = (props) => {
}, [closeSidebar]);

return (
<SidebarPopup open={selected && isVisible} ref={nodeRef}>
<SidebarPopup open={selected && isVisible}>
<InlineForm
schema={schema}
title={
Expand Down
2 changes: 1 addition & 1 deletion src/hocs/withScreenHeight.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function withScreenHeight(WrappedComponent) {
}
};
/* eslint-disable-next-line */
}, []);
}, [isScreenHeight]);

const getScreenHeight = () => {
if (!screenHeight) return null;
Expand Down

0 comments on commit a5c0c68

Please sign in to comment.