chore: Set modal as the selected widget when clicked (#11363)

This commit is contained in:
Nithin David Thomas 2024-12-04 00:24:08 -08:00 committed by GitHub
parent f5cab90b5c
commit a609b3cd7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -290,8 +290,19 @@ const Component = ({ children, ...restProps }) => {
} = restProps['modalProps'];
const setSelectedComponentAsModal = useStore((state) => state.setSelectedComponentAsModal, shallow);
// When the modal body is clicked capture it and use the callback to set the selected component as modal
const handleModalBodyClick = (event) => {
const clickedComponentId = event.target.getAttribute('component-id');
// Check if the clicked element is part of the modal canvas & same widget with id
if (id === clickedComponentId) {
setSelectedComponentAsModal(id);
}
};
return (
<BootstrapModal {...restProps}>
<BootstrapModal {...restProps} onClick={handleModalBodyClick}>
{showConfigHandler && (
<ConfigHandle
id={id}