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

[SwipeableDrawer] Prevent interaction with the drawer content if no opened #11091

Merged
merged 1 commit into from
Apr 22, 2018

Conversation

leMaik
Copy link
Member

@leMaik leMaik commented Apr 21, 2018

Disabling pointer events when the drawer is not open (e.g. swiping) fixes clicking in discovery mode and also prevents accidentially clicking something while swiping (which is annoying).

I used the paper's style attribute because passing classes down into the "inherited" component would break just inheriting the classes. The same reason why I introduced SwipeArea instead of making that component inline. 😕 I'm curious if there is a better solution, so please tell me! 👍

Fixes #10844

Edit: Better (= no inline-style) way: We could add pointerEvents: 'none' in the drawer, using another style classname for the Paper element. That, however, would put a fix for the SwipeableDrawer into the drawer.

@leMaik leMaik requested a review from oliviertassinari April 21, 2018 20:23
@leMaik leMaik added component: drawer This is the name of the generic UI component, not the React module! bug 🐛 Something doesn't work labels Apr 21, 2018
@oliviertassinari
Copy link
Member

I'm curious if there is a better solution, so please tell me!

@leMaik This is an interesting problem. The withStyles() component "blocks" the propagation of the classes property. If we start adding the HOC to SwipeableDrawer, users will no longer be able to override the CSS of the underlying component: the Drawer. In the past, we have been dodging the issue with a DrawerClasses property (you can find the xxxClasses pattern on different components). It's someting we could do here too. But the inline-style solution isn't that bad :).

@oliviertassinari oliviertassinari merged commit 5eacba1 into mui:v1-beta Apr 22, 2018
@leMaik
Copy link
Member Author

leMaik commented Apr 22, 2018

@oliviertassinari Already faced that problem when adding the CSS classes for the discovery area for #11031. It would be cool if propagating classes through inheriting components would just work with withStyles, maybe with some inheritClasses: true option? 🤔

@leMaik leMaik deleted the fix-10844 branch April 22, 2018 13:28
@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 22, 2018

It would be cool if propagating classes through inheriting components would just work with withStyles, maybe with some inheritClasses: true option?

@leMaik We have had the same feedback from @fzaninotto here.
The CSS is already cascading, having the same behavior for the classes property would made debugging much harder. I took a strong implementation bias by not allowing it. So I'm against having class inheritance by default.

Regarding adding a inheritClasses: true option, I'm more neutral. But I can try to propose alternatives. What do you think?

const styles = {
  div: {
    color: 'green',
  },
  span: {
    color: 'yellow',
  }
};

function MyApp(props) {
- const { classes } = props
+ const { classes: { span, ...classes } } = props
  return (
-   <span className={classes.span}>
+   <span className={span}>
-     <MyComponent classes={classes} /> // fails because MyComponent doesn't have a `span` style
+     <MyComponent classes={classes} />
    </span>
  )
}

export default withStyles(styles)(MyApp);
  • From your issue:
const styles = {
  paper: {
    width: 300,
  },
};

function MyApp(props) {
  const { classes } = props
- return <SwipeableDrawer classes={classes} />
+ return <SwipeableDrawer DrawerClasses={classes} />
}

export default withStyles(styles)(MyApp);

@leMaik
Copy link
Member Author

leMaik commented Apr 30, 2018

@oliviertassinari I tried the first solution before and something didn't work, I don't remember what it was. I'll try again soon.

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!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants