-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix/#6216 MultiSelect - SelectionLimit issue #6218
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Ignored Deployments
|
@@ -653,6 +657,10 @@ export const MultiSelect = React.memo( | |||
return ObjectUtils.isFunction(props.optionDisabled) ? props.optionDisabled(option) : ObjectUtils.resolveFieldData(option, props.optionDisabled); | |||
} | |||
|
|||
if (props.selectionLimit && props.value && props.value.length >= props.selectionLimit && !isSelected(option)) { |
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.
I don't understand why this check is needed. If the user exceeds the selected limit, other options do not need to be disabled.
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.
Hi @mertsincan
So how should selectionLimit
work? Can users select more than the selection limit?
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.
according to prime react JSDoc selection limit should limit the amount of selections.
This is obviously a broken prop
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.
OK I made some tweaks and thoroughly tested this. It is in line with how PrimeNG and PrimeVue handle this scenario. @mertsincan the reason we need to check if the current option is already selected is to allow them to unselect it. So in the scenario of selectionLimit={1}
they need to be able to unselect the selected one
this is an issue for my team as well - when trying to add any selection limit - the component still allows us to select as many as we want. If I have a multi select of 50 and want a limit of 2, adding selectionLimit does not limit users from selecting more than 2 https://stackblitz.com/edit/vitejs-vite-qu7tmj?file=src%2FApp.tsx |
Defect Fixes
Fix: #6121 MultiSelect - SelectionLimit issue
Fix #6391