Fixed modal closing issue & select widgets inside modal (#5832)

This commit is contained in:
Kavin Venkatachalam 2023-03-24 18:57:23 +05:30 committed by GitHub
parent 67e0618210
commit d292d26fdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 13 deletions

View file

@ -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 }) => {
<BootstrapModal.Header style={{ ...customStyles.modalHeader }}>
<BootstrapModal.Title id="contained-modal-title-vcenter">{title}</BootstrapModal.Title>
{!hideCloseButton && (
<span className="cursor-pointer" size="sm" onClick={() => hideModal()}>
<span
className="cursor-pointer"
size="sm"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
hideModal();
}}
>
<svg
xmlns="http://www.w3.org/2000/svg"
className="icon icon-tabler icon-tabler-x"

View file

@ -211,6 +211,10 @@ export const DraggableBox = function DraggableBox({
}}
onMouseLeave={() => onComponentHover?.(false)}
style={getStyles(isDragging, isSelectedComponent)}
onClick={(e) => {
e.stopPropagation();
setSelectedComponent && setSelectedComponent(id);
}}
>
<Rnd
style={{ ...style }}

View file

@ -650,7 +650,6 @@ class EditorComponent extends React.Component {
this.setState({ isSaving: true, appDefinition: newDefinition, appDefinitionLocalVersion: uuid() }, () => {
if (!opts.skipAutoSave) this.autoSave();
});
computeComponentState(this, newDefinition.pages[currentPageId]?.components ?? {});
};
handleInspectorView = () => {