diff --git a/frontend/src/Editor/Components/Modal.jsx b/frontend/src/Editor/Components/Modal.jsx index 36319ad96e..7ce2da473c 100644 --- a/frontend/src/Editor/Components/Modal.jsx +++ b/frontend/src/Editor/Components/Modal.jsx @@ -52,24 +52,16 @@ export const Modal = function Modal({ [setShowModal] ); - useEffect(() => { - if (exposedVariables.show !== showModal) { - setExposedVariable('show', showModal).then(() => fireEvent(showModal ? 'onOpen' : 'onClose')); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [showModal]); - useEffect(() => { const canShowModal = exposedVariables.show ?? false; - if (canShowModal !== showModal) { - setShowModal(canShowModal); - fireEvent(canShowModal ? 'onOpen' : 'onClose'); - } + setShowModal(exposedVariables.show ?? false); + fireEvent(canShowModal ? 'onOpen' : 'onClose'); // eslint-disable-next-line react-hooks/exhaustive-deps }, [exposedVariables.show]); function hideModal() { setShowModal(false); + setExposedVariable('show', false).then(() => fireEvent('onClose')); } const customStyles = { @@ -121,6 +113,7 @@ export const Modal = function Modal({ onClick={(event) => { event.stopPropagation(); setShowModal(true); + setExposedVariable('show', true).then(() => fireEvent('onOpen')); }} > {triggerButtonLabel ?? 'Show Modal'} @@ -205,7 +198,15 @@ const Component = ({ children, ...restProps }) => { {title} {!hideCloseButton && ( - hideModal()}> + { + e.preventDefault(); + e.stopPropagation(); + hideModal(); + }} + > onComponentHover?.(false)} style={getStyles(isDragging, isSelectedComponent)} + onClick={(e) => { + e.stopPropagation(); + setSelectedComponent && setSelectedComponent(id); + }} > { if (!opts.skipAutoSave) this.autoSave(); }); - computeComponentState(this, newDefinition.pages[currentPageId]?.components ?? {}); }; handleInspectorView = () => {