Prevent background modal closure when foreground is rendered/closed #3756
-
Hi, is there a way to prevent background modal from closing when foreground modal is opened/closed.
Whenever the announcement dialog is acknowledged/rendered, the user input dialog is closed. Same thing happens when an ALert is acknowledged/rendered, the user input dialog is closed. I tried to stop event bubbling, but it didn't work. Is there a way to prevent this behavior? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
🤖 Hey there, @hema-segment! 🎉 I'm Dosu, a bot here to help you tackle bugs, answer your questions, and guide you on contributing while we wait for a human maintainer to swoop in. Think of me as your friendly neighborhood assistant in this coding journey. 😄 I'm diving into your issue about modal behavior right now and will get back to you with a more detailed response shortly! |
Beta Was this translation helpful? Give feedback.
-
Disclaimer: This is a very experimental bot using OpenAI's GPT-4. The answers may not be correct, a human will review the answer and update it if necessary. Sorry, I don't know how to help with that. I did do a search though, and I managed to find these other Discussions that might be similar or related to your question. Give them a read to see if they answer your question. If they do, head back here and update this discussion and mark it as answered, pointing others to the related discussion:
|
Beta Was this translation helpful? Give feedback.
-
🤖 Based on the current implementation of modals in the Paste codebase, it seems like the behavior you're experiencing might be due to how the If you have multiple modals open at the same time and they're all using the same state variable to determine whether they're open or closed, dismissing one modal could inadvertently close all of them. This is because the One way to prevent this behavior might be to use separate state variables for each modal. For example: const [isModal1Open, setIsModal1Open] = React.useState(true);
const [isModal2Open, setIsModal2Open] = React.useState(true);
const handleModal1Close = (): void => setIsModal1Open(false);
const handleModal2Close = (): void => setIsModal2Open(false);
// ...
<Modal ariaLabelledby={modal1HeadingID} isOpen={isModal1Open} onDismiss={handleModal1Close} size="default">
{/* Modal 1 contents */}
</Modal>
<Modal ariaLabelledby={modal2HeadingID} isOpen={isModal2Open} onDismiss={handleModal2Close} size="default">
{/* Modal 2 contents */}
</Modal> In this example, each modal has its own As for the issue with the I hope this helps! If you're still having trouble, could you provide a bit more information about how you're using the SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Hey @hema-segment Can you also provide a minimal reproduction in Codesandbox for us? Might also be event propagation related too, if it's not state or onDismiss handling. |
Beta Was this translation helpful? Give feedback.
-
Hey @hema-segment - do you still need help with this discussion? |
Beta Was this translation helpful? Give feedback.
-
Multiple possible solutions were provided during office hours. The recording can be found in Slack. |
Beta Was this translation helpful? Give feedback.
Multiple possible solutions were provided during office hours. The recording can be found in Slack.