Skip to content

fixed maxChips props when chips passed as prop #2680

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

Merged
merged 5 commits into from
Apr 2, 2024

Conversation

adids1221
Copy link
Contributor

Description

ChipsInput - maxChips prop support when passing chips list as a prop.

Changelog

ChipsInput - maxChips prop support when passing chips list as a prop.

Additional info

#2166

@M-i-k-e-l
Copy link
Collaborator

When adding the example in the ticket to the PlaygroundScreen I get a red screen:

<Incubator.ChipsInput maxChips={1} multiline={false} chips={[{label: 'Falcon 9'}, {label: 'Enterprise'}]}/>

@adids1221
Copy link
Contributor Author

When adding the example in the ticket to the PlaygroundScreen I get a red screen:

<Incubator.ChipsInput maxChips={1} multiline={false} chips={[{label: 'Falcon 9'}, {label: 'Enterprise'}]}/>

fixed

@stale
Copy link

stale bot commented Oct 15, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 15, 2023
@M-i-k-e-l M-i-k-e-l removed the wontfix label Oct 15, 2023
Copy link

stale bot commented Dec 15, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Dec 15, 2023
@M-i-k-e-l M-i-k-e-l removed the wontfix label Dec 17, 2023
Copy link
Collaborator

@M-i-k-e-l M-i-k-e-l left a comment

Choose a reason for hiding this comment

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

Oops, forgot to send...

Comment on lines 141 to 146
if (maxChips && index < maxChips) {
return renderChip({index, chip, isMarkedForRemoval});
}
if (!maxChips) {
return renderChip({index, chip, isMarkedForRemoval});
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (maxChips && index < maxChips) {
return renderChip({index, chip, isMarkedForRemoval});
}
if (!maxChips) {
return renderChip({index, chip, isMarkedForRemoval});
}
if (!maxChips || (maxChips && index < maxChips)) {
return renderChip({index, chip, isMarkedForRemoval});
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

And maxChips is missing from the dependencies

@adids1221 adids1221 requested a review from M-i-k-e-l February 18, 2024 08:51
Copy link
Collaborator

@M-i-k-e-l M-i-k-e-l left a comment

Choose a reason for hiding this comment

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

Approved
When looking at it again I am pretty sure we can shorten the line even more:

if (!maxChips || index < maxChips) {

@adids1221 adids1221 requested a review from M-i-k-e-l February 18, 2024 10:35
@adids1221 adids1221 merged commit eb25f4d into master Apr 2, 2024
@adids1221 adids1221 deleted the fix/ChipsInput-maxChips branch April 2, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants