Comments (7)
I believe so! That's pretty much what I was thinking. You don't even need to reorder
onClick={handleBackdropClick}
since theonClick
prop won't be part ofothers
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
andonClose (with reason)
handle.I mean why is the dialog root's
onClick
handling the backdrop'sclick
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.
I agree it's a bug.
from material-ui.
Invoke it from within
handleBackdropClick
here (if provided in props) instead of grouping it with...others
.
Where to call handleBackdropClick
then?
from material-ui.
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.
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.
I believe so! That's pretty much what I was thinking. You don't even need to reorder
onClick={handleBackdropClick}
since theonClick
prop won't be part ofothers
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
andonClose (with reason)
handle.
I mean why is the dialog root's onClick
handling the backdrop's click
event?
from material-ui.
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)
- [material-ui] Next.js 14 with NX monorepo build fails on PonyfillGlobal HOT 3
- [docs-infra] Dark mode not persisting after switching from light mode HOT 8
- Module not found: Error: Can't resolve '@mui/base/className' in '/app/node_modules/********/ui-toolkit/node_modules/@mui/material/utils' HOT 1
- [joy-ui][Button] The user can see the text by highlighting when loading is true
- @mui/material incompatible with versions of @types/react > 18.2.60
- [system][docs] Missing content regarding possible Box's styling approaches HOT 1
- Autocomplete popupIcon icon is turning down HOT 3
- [website] Inconsistent card display at 100% zoom level HOT 1
- [system] useColorScheme should return null during hydration
- [material-ui][Menu] Submenu closes improperly HOT 5
- [website] Site responsiveness and adaptability when zooming HOT 4
- [material-ui][Menu] Issues building a context menu HOT 4
- [material-ui] Standardize event handler callbacks
- [material-ui][Autocomplete] click on helperText inside of Autocomplete component triggers input focus/option selection HOT 7
- [material-ui][Switch] Issues with styling before refreshing the page HOT 5
- Styleprovider doesn't seem to work on dynamically rendered components inside shadow dom HOT 5
- [material-ui][Switch] Unsupported color after upgrade @mui/material to 5.15.13 HOT 4
- CSP issue in React Project
- [material-ui][Typography] Migrating from v4 to v5 issue HOT 2
- [joy-ui] The latest betas aren't available on `latest` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-ui.