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

[Drawer] Temporary variant use modal z-index #22562

Closed
1 of 2 tasks
vaibhavM55 opened this issue Sep 11, 2020 · 5 comments
Closed
1 of 2 tasks

[Drawer] Temporary variant use modal z-index #22562

vaibhavM55 opened this issue Sep 11, 2020 · 5 comments
Labels
component: drawer This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement

Comments

@vaibhavM55
Copy link

I was trying to implement a drawer in my application and was following this example https://material-ui.com/components/drawers/#clipped-under-the-app-bar

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

As shown in the example, you should set the z-index of the appbar as theme.zIndex.drawer + 1 and this would cause the appbar to raise over the drawer. But this is not happening when I tried it.

const styles = theme => {
  console.log("z-index: ", theme.zIndex.drawer, theme.zIndex.appBar);
  return {
    appBar: {
      backgroundColor:
        theme.palette.type === "dark" ? grey[800] : theme.palette.primary,
      // zIndex: theme.zIndex.drawer + 1,
      // zIndex: theme.zIndex.drawer + 99,
      // zIndex: theme.zIndex.drawer + 101,
      zIndex: 1301,
    },
  };
};

As you can see, I tried checking if the theme.zIndex.drawer value was passed, which it was. I also, I tried setting the z-index to the hard coded value of 5000 to see if the property is valid and there are no errors in the code. And the appBar was raised above the drawer. But setting it to a hard coded value of 1201 didn't work.

So, I thought of checking the value which makes it work and tried different values. It works when its set to 1301 and doesn't work for anything below. I can't figure out why. I have not set the zIndex of any other component in my app. This is the first time I am trying to change a component's (AppBar) zIndex value.

After I tried to reproduce as asked below in codesandbox, I figured out it was an issue with the temporary drawer as the permanent variant seems to work perfectly.

Expected Behavior 🤔

As shown in the example and also logically, it should work when its set over 1200 which is the z-index of the drawer.

Steps to Reproduce 🕹

Steps:

  1. Use the codesandbox example provided by the official website for clipped under the bar drawer example https://codesandbox.io/s/u1rq6
  2. Go into the demo.js file
  3. Remove the variant = "permanent" prop from the <Drawer> component
  4. Add open = {true}

Context 🔦

As described in the docs

Apps focused on productivity that require balance across the screen.

Your Environment 🌎

Tech Version
Material-UI core -> 4.11.0
React 16.13.1
Browser chrome
TypeScript no
etc.
@vaibhavM55 vaibhavM55 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 11, 2020
@oliviertassinari oliviertassinari added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 11, 2020
@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 11, 2020

@oliviertassinari oliviertassinari added component: drawer This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement and removed status: waiting for author Issue with insufficient information labels Sep 11, 2020
@vaibhavM55
Copy link
Author

Thanks for the quick reply. I didn't know temporary drawer was considered as a modal internally as it wasn't mentioned anywhere in the docs. So, as you can see, I did waste a lot of time because of it.

You should definitely mention it in the documentation of the temporary drawer or the clipped under the app bar example.

@oliviertassinari oliviertassinari changed the title The AppBar and Drawer (temporary variant) z-index has unexpected behaviour [Drawer] Temporary variant use modal z-index Sep 11, 2020
@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 11, 2020

@vaibhavM55 You can some of the information from the dev tools.

Capture d’écran 2020-09-11 à 22 47 23

I think that this issue will do it just fine for the documentation. Thanks for opening it.

@vaibhavM55
Copy link
Author

Thanks again, But it would be nice to have it mentioned in the documentation as its not entirely intuitive that the drawer will have different z-index based on the variant types. So, please do consider it.

Also, I assume that the reason temporary drawer has the same z-index as modal, is because its based upon modal. Am I right in my assumption? If so, is it possible that the temporary drawer has less z-index than the modal, like say 1250 ? Since I was just now trying to wrap my head around how I would deal with the appbar and the drawer to get the clipped under effect.

Since, if I now do something like setting the app z-index to zIndex: theme.zIndex.modal + 1, then I would get the effect, but then my appbar would also be above the modals that I would use. So, inorder to get rid of that, I would have to then set the zIndex of all my modals to something like 1350 in the createMuiTheme hook.

@vaibhavM55
Copy link
Author

Also, to get around the issue mentioned above of changing the modal z-index and all, I tried setting the z-index on my temporary drawer to 1250 and my appbar to 1251 using the makeStyles hook, but that does not seem to work.

https://codesandbox.io/s/material-demo-forked-3cdnx?file=/demo.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: drawer This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

2 participants