-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested <Tearsheet> components not working as intended #2452
Comments
@Pasoon Could you provide a reduced case CodeSandbox so we can better investigate this behavior? Our Storybook examples are working so we’d like to better understand how you and your team are using it. |
@elycheea It happens when you have the second Tearsheet nested inside the first one instead of adjacent to each other. <Tearsheet title="Tearsheet 1">
Content for tearsheet 1
<Tearsheet title="Tearsheet 2">
Content for tearsheet 2
</Tearsheet>
</Tearsheet> |
@elycheea Here is a quick reproduction: https://codesandbox.io/s/upbeat-tess-fi104p?file=/src/index.js Interestingly enough the focus stealing is fixed whenever you blur the browser and then re-focus. |
Hi @elycheea, any updates on this issue? |
Here's a Codesandbox reproducing the nested Open the second nested Tearsheet, and you'll see that the |
Unassigning @matthewgallo for now for. Hoping @davidmenendez or I can take a look at this some more this week. |
Great to hear back from you. Now that is also affecting us and hear from other teams it happens as well. Would be great if you can periodize this further. |
So we noticed more: Two things:
|
@Pasoon is there a specific reason why the tearsheets have to be nested? we have an example of how to use stacking tearsheets with the code here. i'll look into this, but just wanted to point this out as an existing implementation. |
that's reasonable.
i was not able to replicate this. if i'm understanding this correctly, you're saying that when using stacking tearsheets, if tearsheet 1 has no actions and then you open tearsheet 2, which has actions, that clicking in or out of the tearsheet will close tearsheet 1? |
@janhassel i have a feeling this is because create tearsheet has it's own special focus functionality. i'll investigate further. |
Thanks for looking into this, and the code sample, @davidmenendez! In the linked example, the Tearsheets, while visually stacked, are on the same level in the code. Sometimes when we're designing a feature, we might want to separate the Tearsheets into different levels, for better code layout & organization. And to prevent having a single bloated React component containing all the Tearsheets, and the related state...etc. |
Yes. If I have stack Tearsheets than clicking outside of Tearsheet 2 closes 2 AND 1. Note that you need to have the Tearsheet nested on INTO another: Say Tearsheet 1 is the parnet component of Tearsheet 2 |
@davidmenendez if you’re reaching out to Carbon, please add more detail on this. @matthewgallo shared that there’s a Dialog component now as well ... probably a big change but could be worth considering for the stacking (probably Carbon 11 only). |
after the last DSAG meeting it was determined that we need to explore solutions for the nested modal problem. At the request of the other DSAG members i've gone ahead and created a mural for this exploration https://app.mural.co/invitation/mural/watsonassistant2719/1688405516721?sender=dmenend6705&key=ab296ce7-8698-4423-a824-df2c130e2065 |
@davidmenendez We’ll put this on hold until we get get some progress through DSAG but should bring this back up on the next call. |
I just added an example for stacking tearsheets to the Mural, but our developers say that this is not currently possible due to this issue. Is there any update on the fix for this issue? We are urgently trying to deliver this design. cc: @Ashley-Bock |
Is there any update on this issue esp. progress in allowing focusing on the tearsheet? Besides using the input fields, keyboard events are also not possible which causes further accessibility issues. |
It seems the issue is caused by the focus event bubbling in React tree. If we could stop the event propagation in the nested tearsheet, the focus isn't lost. <div
ref={tearsheetWrapperRef}
onFocus={(e) => {
if (!tearsheetWrapperRef.current?.contains(document.activeElement)) {
e.stopPropagation();
}
}}
>
<SecondTearsheet
isOpen={isSecondTearhsheetOpen}
onClose={() => setIsSecondTearhsheetOpen(false)}
/>
</div>; We may not need this workaround when the issue is fixed, but writing here as it might help other people. |
based on the last comment by @makafsal looks like this is now working. closing as complete. |
What package(s) are you using?
Detailed description
When opening another tearsheet within another tearsheet (nested), you can't interact with any form or input, it does not let you focus or type into the input boxes.
Tearsheet component
I should be able to use nested Tearsheets
Chrome
version ^1.32.0
Steps to reproduce the issue
Additional information
Screen.Recording.2022-11-09.at.2.05.07.PM.mov
The text was updated successfully, but these errors were encountered: