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

[Dialog] Remove disableEscapeKeyDown prop, in favor of using the onClose callback #27306

Open
nzayatz14 opened this issue Jul 15, 2021 · 11 comments
Labels
breaking change component: dialog This is the name of the generic UI component, not the React module! discussion

Comments

@nzayatz14
Copy link

nzayatz14 commented Jul 15, 2021

Is there any particular reason that the disableBackdropClick prop is deprecated on the Dialog component but the disableEscapeKeyDown prop is not?

I feel like they should either both be deprecated and handled the same way via the handleClose function, or neither should be deprecated.

Docs (v4.12.1) are currently showing:

Screen Shot 2021-07-15 at 2 23 31 PM

@nzayatz14 nzayatz14 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 15, 2021
@michal-perlakowski
Copy link
Contributor

From the pull request that removed disableBackdropClick:

disableEscapeKeyDown is on the chopping block as well but will be handed separately.

@nzayatz14
Copy link
Author

Ok sounds good, just wanted to make sure things were remaining consistent

@mnajdova
Copy link
Member

We will probably need to move this to v6. The reason is that the property still exists in v5, and we wouldn't like to introduce more braking changes now that we are in beta. Thanks for the report @nzayatz14

@mnajdova mnajdova added this to the v6 milestone Jul 16, 2021
@mnajdova mnajdova added breaking change component: dialog This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 16, 2021
@mnajdova mnajdova changed the title disableBackdropClick deprecated on Dialog component but disableEscapeKeyDown is not [Dialog] Remove disableEscapeKeyDown prop, in favor of using the onClose callback Jul 16, 2021
@eps1lon
Copy link
Member

eps1lon commented Jul 17, 2021

This is fine for v5. Otherwise the API just looks weird as mentioned in the issue description. I just forgot to do it.

@eps1lon eps1lon self-assigned this Jul 17, 2021
@eps1lon
Copy link
Member

eps1lon commented Jul 17, 2021

On the other hand, Modal also does stop event propagation which is a bit scary to change. Let's do this in v6.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 17, 2021

Is there any particular reason that the disableBackdropClick prop is deprecated on the Dialog component but the disableEscapeKeyDown prop is not?

@nzayatz14 Yes. It's similar to the other events but not identical. The motivation to keep it was to kill two birds (not call on click + call event.stopPropagation()) in one stone (disableEscapeKeyDown). It's meant as a helper with a pit of success. If we remove it, developers would have to not forget to call event.stopPropagation(), they will get bad surprises otherwise.

@eps1lon
Copy link
Member

eps1lon commented Jul 17, 2021

If we remove it, developers would have to not forget to call event.stopPropagation(), they will get bad surprises otherwise.

This is misleading.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 21, 2021

As far as I know, we should close this issue. We don't yet have a case around the problem that we would fix. The concern around API consistency was addressed by highlighting that the props have a different behavior.


This is misleading.

@eps1lon Happy to have a longer conversation about it. I guess there are multiple different ways to see this problem.

  1. stopPropagation vs. preventDefault. react-modal uses stopPropagation while bootstrap uses preventDefault. Who is right?

In #14991, we use the feedback in #13470 (comment) that makes the case for only using preventDefault for preventing default user-agent behaviors.

This article https://css-tricks.com/dangers-stopping-event-propagation/ makes the case for avoiding stopPropagation unless we absolutely want no other parent event handlers to know about the events. It's why it call stopPropagation in the Autocomplete because it strongly assumes that nobody else should handle the event.
https://github.com/mui-org/material-ui/blob/913461139a7a275230bf4e960064646bb90ccc54/packages/material-ui/src/useAutocomplete/useAutocomplete.js#L778-L785

  1. should the modal manipulate the event with its default props? It currently does, hence why we need disableEscapeKeyDown to disable the built-in behavior. This answers the question of @nazartokar:
    "Is there any particular reason that the disableBackdropClick prop is deprecated on the Dialog component but the disableEscapeKeyDown prop is not?"

@oliviertassinari oliviertassinari removed this from the v6 milestone Aug 15, 2021
@oliviertassinari
Copy link
Member

Regarding how we manage the product. Up until now, as the owner of it, I have used the milestones to include problems to fix in order to reach a specific larger goal. So I have removed the v6 milestone from this issue because we haven't yet a clear consensus on the direction the product should take on this one.

Now, we could act on a different way to manage milestones, by including issues that have been less processed. Meaning we would including potential opportunities, even if half never get into the final shipped outcome. It would be a different tradeoffs. The advantage is that it avoid us to forgot about something, and allows for more exploration, the disadvantage is that we might end up with never ending milestones. With the latter tradeoff, we can use the "discussion" label to signal that we haven't yet dive enough into the problem, and the product owner would have to be conscious about not making the scope of the milestones grow forever, removing issues when needed.

@eps1lon eps1lon added this to the v6 milestone Aug 18, 2021
@joelbourbon
Copy link

Hey guys, just wanted to bring up that deprecating those fields makes it kindof impossible out of the box to disableBackdropClick or disableEscapeKeyDown at large in createTheme.

Since it is not an actual event received in onClose you cannot event overload it generally and stopPropagation or preventDefault or whatever.

I would love to bring a solution to the problem, but this is over my head 😅

@teaganga
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: dialog This is the name of the generic UI component, not the React module! discussion
Projects
Status: Stalled
Development

Successfully merging a pull request may close this issue.

8 participants