Skip to content

Conversation

@codiini
Copy link
Contributor

@codiini codiini commented Jan 16, 2026

Summary

Fixes #47234

The Chip's delete icon handler was unconditionally calling event.stopPropagation(), which prevented click events from reaching parent listeners like ClickAwayListener. 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 an onClick handler. 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

  • Modified handleDeleteIconClick in Chip.js to conditionally call stopPropagation() only when onClick is defined
  • Added a test case to verify that click events propagate to parent handlers when no onClick is present

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
@mui-bot
Copy link

mui-bot commented Jan 16, 2026

Netlify deploy preview

https://deploy-preview-47628--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 🔺+49B(+0.01%) 🔺+9B(+0.01%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against b597ca4

@zannager zannager added the scope: chip Changes related to the chip. label Jan 16, 2026
@zannager zannager requested review from mj12albert and siriwatknp and removed request for siriwatknp January 16, 2026 12:52
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a 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

@codiini
Copy link
Contributor Author

codiini commented Jan 19, 2026

@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

Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a 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?

@ZeeshanTamboli ZeeshanTamboli dismissed their stale review January 19, 2026 13:42

Works well now

@ZeeshanTamboli ZeeshanTamboli added the type: bug It doesn't behave as expected. label Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: chip Changes related to the chip. type: bug It doesn't behave as expected.

4 participants