Skip to content
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

[docs][Drawer] Fix Right-anchored persistent drawer intercepts click when it is closed #38760

Closed
wants to merge 2 commits into from

Conversation

alzaar
Copy link

@alzaar alzaar commented Sep 2, 2023

I am opening this up to verify the pipeline tests and will finalize the PR once the pipeline is green.

Fixes #29997

Before: https://mui.com/material-ui/react-drawer/#persistent-drawer
After: https://deploy-preview-38760--material-ui.netlify.app/material-ui/react-drawer/#persistent-drawer

@mui-bot
Copy link

mui-bot commented Sep 2, 2023

Netlify deploy preview

https://deploy-preview-38760--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 710493b

@zannager zannager added the component: drawer This is the name of the generic UI component, not the React module! label Sep 4, 2023
@zannager zannager requested a review from mnajdova September 4, 2023 10:45
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alzaar Will you be working on it further?

@alzaar
Copy link
Author

alzaar commented Sep 12, 2023

@ZeeshanTamboli Yes, I will be continuing with this. Is there an urgency to wrap this up ?

@ZeeshanTamboli
Copy link
Member

No urgency, just wanted to make sure its active.

@alzaar
Copy link
Author

alzaar commented Sep 16, 2023

Hi @ZeeshanTamboli Would it be possible to get this reviewed ? It addresses this issue

@ZeeshanTamboli ZeeshanTamboli changed the title Issue 29997 [docs][Drawer] Fix Right-anchored persistent drawer intercepts click when it is closed Sep 25, 2023
@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work docs Improvements or additions to the documentation package: material-ui Specific to @mui/material labels Sep 25, 2023
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alzaar Thanks for the PR! If we add a z-index to the right-anchored persistent drawer, it raises a question: why isn't it added to the left-anchored drawer?

According to the documenation:

The drawer sits on the same surface elevation as the content.

so adding a zIndex isn't the correct approach.

The proper solution is to add position: "relative" to the main content:

--- a/docs/data/material/components/drawers/PersistentDrawerRight.js
+++ b/docs/data/material/components/drawers/PersistentDrawerRight.js
@@ -37,6 +37,8 @@ const Main = styled('main', { shouldForwardProp: (prop) => prop !== 'open' })(
       }),
       marginRight: 0,
     }),
+    // This is necessary to enable the selection of content. In the DOM, the stacking order is determined by the order o
f appearance. Following this rule, elements appearing later in the markup will overlay those that appear earlier. Since t
he Drawer comes after the Main content, this adjustment ensures proper interaction with the underlying content.
+    postion: 'relative',
   }),
 );

diff --git a/docs/data/material/components/drawers/PersistentDrawerRight.tsx b/docs/data/material/components/drawers/Pers
istentDrawerRight.tsx
index f4f300d84f..b95b6fd1da 100644
--- a/docs/data/material/components/drawers/PersistentDrawerRight.tsx
+++ b/docs/data/material/components/drawers/PersistentDrawerRight.tsx
@@ -38,6 +38,8 @@ const Main = styled('main', { shouldForwardProp: (prop) => prop !== 'open' })<{
     }),
     marginRight: 0,
   }),
+  // This is necessary to enable the selection of content. In the DOM, the stacking order is determined by the order of
appearance. Following this rule, elements appearing later in the markup will overlay those that appear earlier. Since the
 Drawer comes after the Main content, this adjustment ensures proper interaction with the underlying content.
+  postion: 'relative',
 }));

 interface AppBarProps extends MuiAppBarProps {

This will put the un-positioned element (Drawer) below the positioned element (Main). Check out the following article - https://www.freecodecamp.org/news/4-reasons-your-z-index-isnt-working-and-how-to-fix-it-coder-coder-6bc05f103e6c/

@alzaar
Copy link
Author

alzaar commented Sep 28, 2023

Thanks @ZeeshanTamboli. This was insightful, I will make the changes and push 'em up.

- Add potential fix
- Look up how to make a PR
- Trigger pipeline to verify fix
- Check if pipeline can be run locally
Comment on lines +106 to +108
sx={{
position: 'relative',
}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using the sx prop. Instead, follow the above comment and add it to the styled component.

@ZeeshanTamboli
Copy link
Member

@alzaar Since I couldn't make changes to your PR, I added the modifications in a different PR, which is #39318. Thanks for your PR and your interest in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: drawer This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docs][Drawer] Right-anchored persistent drawer intercepts click while closed
5 participants