Skip to content
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

Merged
merged 19 commits into from Dec 19, 2022

Conversation

sai6855
Copy link
Contributor

@sai6855 sai6855 commented Dec 9, 2022

Closes: #35188

This PR adds onDelete prop to ChipDelete component, onDelete fires when user clicks on component or presses Backspace or enter.

@sai6855 sai6855 changed the title [ChipDelete] added onDelete prop to ChipDelete [ChipDelete] Add onDelete prop to ChipDelete Dec 9, 2022
@mui-bot
Copy link

mui-bot commented Dec 9, 2022

Messages
📖 Netlify deploy preview: https://deploy-preview-35412--material-ui.netlify.app/

@mui/joy: parsed: +0.07% , gzip: +0.14%

Details of bundle changes

Generated by 🚫 dangerJS against 0e7dc3b

@oliviertassinari oliviertassinari added the component: chip This is the name of the generic UI component, not the React module! label Dec 11, 2022
@sai6855
Copy link
Contributor Author

sai6855 commented Dec 13, 2022

@ZeeshanTamboli can you review this PR

@ZeeshanTamboli ZeeshanTamboli added new feature New feature or request accessibility a11y labels Dec 13, 2022
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.

Looks good mostly

packages/mui-joy/src/ChipDelete/ChipDelete.tsx Outdated Show resolved Hide resolved
packages/mui-joy/src/ChipDelete/ChipDelete.test.js Outdated Show resolved Hide resolved
packages/mui-joy/src/ChipDelete/ChipDelete.tsx Outdated Show resolved Hide resolved
packages/mui-joy/src/ChipDelete/ChipDelete.tsx Outdated Show resolved Hide resolved
packages/mui-joy/src/ChipDelete/ChipDelete.tsx Outdated Show resolved Hide resolved
@ZeeshanTamboli ZeeshanTamboli added the package: joy-ui Specific to @mui/joy label Dec 13, 2022
@sai6855
Copy link
Contributor Author

sai6855 commented Dec 13, 2022

@ZeeshanTamboli updated code as described, but ci/circleci: checkout test is failing. i'm not able to fix it, can you check it once

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.

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.

@sai6855
Copy link
Contributor Author

sai6855 commented Dec 14, 2022

@ZeeshanTamboli updated changes also added onDelete prop description in docs.
preview: https://deploy-preview-35412--material-ui.netlify.app/joy-ui/react-chip/#delete-button

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.

@ZeeshanTamboli
Copy link
Member

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 onDelete code from the demo. Just the text is enough.

@sai6855 sai6855 requested review from ZeeshanTamboli and removed request for siriwatknp December 14, 2022 17:36
};

const handleKeyDelete = (event: React.KeyboardEvent<HTMLButtonElement>) => {
event.preventDefault();
Copy link
Member

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()?

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@siriwatknp siriwatknp left a 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.

@mnajdova mnajdova changed the title [ChipDelete] Add onDelete prop to ChipDelete [ChipDelete][joy] Add onDelete prop to ChipDelete Dec 16, 2022
@siriwatknp siriwatknp merged commit e195455 into mui:master Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y component: chip This is the name of the generic UI component, not the React module! new feature New feature or request package: joy-ui Specific to @mui/joy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ChipDelete][Joy] Support backspace key press
5 participants