8000 Fix multiselect chip clear for labeled user profile options by blakefrain · Pull Request #55021 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Fix multiselect chip clear for labeled user profile options - #55021

Open
blakefrain wants to merge 3 commits into
keycloak:mainfrom
blakefrain:main
Open

blakefrain wants to merge 3 commits into
keycloak:mainfrom
blakefrain:main

Conversation

@blakefrain
Copy link
Copy Markdown

Fixes clearing and saving empty values for user profile attributes with inputType=multiselect when inputOptionLabels differ from option keys.

Root cause

Chip removal used display labels as selections while 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 toUserFormFields from 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.

cursoragent and others added 3 commits November 10, 2026 22:16
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.
Copilot AI balanced review requested due to automatic review settings November 11, 2026 00:13
@blakefrain
blakefrain requested review from a team as code owners November 11, 2026 00:13
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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

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.

Multiselect user profile attribute chips cannot be cleared when inputOptionLabels differ from option keys

3 participants

0