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
[ChipDelete][joy] Add onDelete prop to ChipDelete #35412
Conversation
@mui/joy: parsed: +0.07% , gzip: +0.14% |
@ZeeshanTamboli can you review this PR |
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.
Looks good mostly
@ZeeshanTamboli updated code as described, but ci/circleci: checkout test is failing. i'm not able to fix it, can you check it once |
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.
IMO, we should also add a statement in the docs here: https://mui.com/joy-ui/react-chip/#delete-button to say:
The `onDelete` callback is fired on `ChipDelete` when the chip is deleted.
@ZeeshanTamboli updated changes also added onDelete prop description in docs. but test-types test is failing not sure why, it is asking to run yarn docs:typescript:formatted but when i ran yarn docs:typescript:formatted DeletableChip.tsx.preview file is got deleted. |
Then I would suggest to remove |
}; | ||
|
||
const handleKeyDelete = (event: React.KeyboardEvent<HTMLButtonElement>) => { | ||
event.preventDefault(); |
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.
What is the use case for preventDefault()
?
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.
handleKeyDelete is firing twice for 1 keypress , e.preventDefault() is preventing that
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.
Then it should be specific for those keys. Currently, TAB
is stuck on the chip delete.
Screen.Recording.2565-12-15.at.11.35.18.mov
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.
Got it so e.prevantDefault() should be inside if block, since you are committing to the pr will you make the change or should I.
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.
Got it, I can push the change.
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.
Sorry, I just pushed it. Hope it's fine
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.
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.
👍 Looks great!, thanks for your contribution.
Closes: #35188
This PR adds onDelete prop to ChipDelete component, onDelete fires when user clicks on component or presses Backspace or enter.