-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[Chip] Fix delete icon stopPropagation blocking ClickAwayListener #47628
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
base: master
Are you sure you want to change the base?
Conversation
Only call event.stopPropagation() on delete icon click when the Chip has an onClick handler. This allows click events to propagate to parent listeners like ClickAwayListener when the Chip only has onDelete. Fixes mui#47234
Netlify deploy previewhttps://deploy-preview-47628--material-ui.netlify.app/ Bundle size report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work if the chip is clickable and deletable. See StackBlitz pointing to this PR build: https://stackblitz.com/edit/gibkpfdb?file=src%2FApp.tsx
|
@ZeeshanTamboli I've made updates to the PR. Should work now. Please review. Stackblitz URL for updated PR build: https://stackblitz.com/edit/gibkpfdb-ujpaaqbe?file=src%2FApp.tsx |
ZeeshanTamboli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works well if I test it. But I am worried if there could be any breaking change here. @mj12albert @siriwatknp Would you mind taking a look?
Summary
Fixes #47234
The Chip's delete icon handler was unconditionally calling
event.stopPropagation(), which prevented click events from reaching parent listeners likeClickAwayListener. This caused issues when a Chip with a delete icon was placed inside a Popper with ClickAwayListener - clicking the delete icon would not close the Popper.This PR changes the behavior to only call
stopPropagation()when the Chip itself has anonClickhandler. This preserves the original intent (preventing the delete click from triggering the Chip's onClick) while allowing events to propagate to parent listeners when the Chip is not clickable.Changes
handleDeleteIconClickinChip.jsto conditionally callstopPropagation()only whenonClickis definedonClickis present