fix: only render modal when explicitly opened to prevent auto-show
Change modal rendering strategy from controlled via 'open' prop to
conditional rendering. Now the Modal component is only added to DOM
when isAddModalOpen is true, preventing it from being present on page load.
Before: {actions.addNew && <Modal open={isAddModalOpen} ...>}
After: {actions.addNew && isAddModalOpen && <Modal ...>}
This ensures the modal cannot accidentally show on page load and cannot be
interfered with when it shouldn't exist.
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -531,17 +531,15 @@ export default function DataTable({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Add New Modal */}
|
||||
{actions.addNew && (
|
||||
{/* Add New Modal - only render when actually open */}
|
||||
{actions.addNew && isAddModalOpen && (
|
||||
<Modal
|
||||
title={actions.addNew.label || __('Add New', 'formipay')}
|
||||
open={isAddModalOpen}
|
||||
onRequestClose={() => {
|
||||
setIsAddModalOpen(false);
|
||||
setNewItemTitle('');
|
||||
}}
|
||||
isDismissible
|
||||
focusOnMount="firstContentElement"
|
||||
>
|
||||
<TextControl
|
||||
__next40pxDefaultSize
|
||||
|
||||
Reference in New Issue
Block a user