Repository navigation
Fix multiselect chip clear for labeled user profile options - #55021
Open
blakefrain wants to merge 3 commits into
Open
blakefrain wants to merge 3 commits into
blakefrain wants to merge 3 commits into
Conversation
When inputOptionLabels differed from option keys, chip selections used display labels while toggle/remove compared against option keys, so clicking X added the label instead of removing the value. Keep option keys as selections, render labeled chips via chipGroupComponent, and clear multiselect to an empty array. Closes keycloak#55020 Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Closes keycloak#55020 Keycloak omits empty attributes from GET user responses. After clearing a multiselect chip and saving, form.reset rebuilt values without that key, so react-hook-form kept the previous nested value and the chip returned. Seed managed profile attributes with empty values when converting to form fields so reset explicitly clears them. Signed-off-by: Cursor Agent <cursoragent@cursor.com>
…ar-5668 Fix multiselect chip clear for labeled user profile options did testing in my home lab and all was working correctly I know this is an issue for multiple businesses.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the multiselect chip-removal and cleared-attribute persistence changes.
No open issues 🎉
What changed in this PR
Fixes labeled user-profile multiselect chip removal in the shared UI and prevents cleared attributes from reappearing after saving in the Admin Console, addressing #55020.
Changes:
- Keeps option keys as selection values while displaying labels in removable chips.
- Seeds missing managed attributes with empty values during Admin Console form resets.
- Adds regression tests for chip removal and empty-value conversion.
| File | Description |
|---|---|
js/libs/ui-shared/src/user-profile/SelectComponent.tsx |
Removes chips by option key and clears multiselect values to empty arrays. |
js/libs/ui-shared/src/user-profile/SelectComponent.test.tsx |
Tests label display and key-based chip removal. |
js/apps/admin-ui/src/user/UserForm.tsx |
Passes profile metadata when resetting the form. |
js/apps/admin-ui/src/user/form-state.ts |
Seeds empty managed attributes before applying server values. |
js/apps/admin-ui/src/user/form-state.test.ts |
Tests empty defaults, server-value precedence, and empty-array serialization. |
js/apps/admin-ui/src/user/EditUser.tsx |
Uses profile metadata when resetting loaded user data. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes clearing and saving empty values for user profile attributes with
inputType=multiselectwheninputOptionLabelsdiffer from option keys.Root cause
Chip removal used display labels as
selectionswhile toggle/remove compared against option keys, so clicking X could add the label instead of removing the value.After a successful clear, PUT sent an empty array and the server removed the attribute, but GET omits empty attributes.
form.reset(toUserFormFields(user))then rebuilt form state without that key, so react-hook-form kept the previous nested value and the chip reappeared until a hard reload.Fix
Keep option keys as selections and render labels via
chipGroupComponent, clearing multiselect to[].Seed managed profile attributes with empty values in
toUserFormFieldsfrom user profile metadata so reset explicitly clears omitted attributes.How to verify
Configure an optional multiselect attribute with an options validator,
inputOptionsFromValidation, and labels that differ from keys (max=1).Select a value, save, clear the chip with X, save again — the field should stay empty and save successfully.
Hard refresh should still show an empty selection.
Closes #55020
AI disclosure
This change was produced with assistance from a Cursor cloud agent.