Giter VIP home page Giter VIP logo

Comments (7)

asif-choudhari avatar asif-choudhari commented on April 28, 2024 2

I believe so! That's pretty much what I was thinking. You don't even need to reorder onClick={handleBackdropClick} since the onClick prop won't be part of others anymore.

Correct. Updated the above diff.

there should be a distinction between clicking the dialog root and clicking the backdrop.

I agree and if I understand the docs correctly, that's the use case that (now deprecated) onBackdropClick and onClose (with reason) handle.

I mean why is the dialog root's onClick handling the backdrop's click event?

DialogRoot is a Styled Modal and the underlying Modal component has the Pop Up(Modal) and Backdrop component with it, By passing onClick to DialogRoot eventually to Backdrop, callback is fired back when Backdrop is clicked to close it.

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on April 28, 2024

I agree it's a bug.

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on April 28, 2024

Invoke it from within handleBackdropClick here (if provided in props) instead of grouping it with ...others.

Where to call handleBackdropClick then?

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on April 28, 2024

Would the following fix work:

--- a/packages/mui-material/src/Dialog/Dialog.js
+++ b/packages/mui-material/src/Dialog/Dialog.js
@@ -182,6 +182,7 @@ const Dialog = React.forwardRef(function Dialog(inProps, ref) {
     fullWidth = false,
     maxWidth = 'sm',
     onBackdropClick,
+    onClick,
     onClose,
     open,
     PaperComponent = Paper,
@@ -211,6 +212,9 @@ const Dialog = React.forwardRef(function Dialog(inProps, ref) {
     backdropClick.current = event.target === event.currentTarget;
   };
   const handleBackdropClick = (event) => {
+    if (onClick) {
+      onClick(event);
+    }
     // Ignore the events not coming from the "backdrop".
     if (!backdropClick.current) {
       return;

However, I believe there should be a distinction between clicking the dialog root and clicking the backdrop.

from material-ui.

ryanburr avatar ryanburr commented on April 28, 2024

I believe so! That's pretty much what I was thinking. You don't even need to reorder onClick={handleBackdropClick} since the onClick prop won't be part of others anymore.

there should be a distinction between clicking the dialog root and clicking the backdrop.

I agree and if I understand the docs correctly, that's the use case that (now deprecated) onBackdropClick and onClose (with reason) handle.

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on April 28, 2024

I believe so! That's pretty much what I was thinking. You don't even need to reorder onClick={handleBackdropClick} since the onClick prop won't be part of others anymore.

Correct. Updated the above diff.

there should be a distinction between clicking the dialog root and clicking the backdrop.

I agree and if I understand the docs correctly, that's the use case that (now deprecated) onBackdropClick and onClose (with reason) handle.

I mean why is the dialog root's onClick handling the backdrop's click event?

from material-ui.

ryanburr avatar ryanburr commented on April 28, 2024

Ah I see what you're saying. Good question. Not sure of the design decision there. Found the commit that put it there though.

Would an alternative be to wire this up through the Backdrop onClick prop? I haven't explored this component much yet.

from material-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.