8000 Fix react-compiler warnings: mutations, debounce, and delete patterns in admin UI by edewit · Pull Request #52904 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Fix react-compiler warnings: mutations, debounce, and delete patterns in admin UI - #52904

Open
edewit wants to merge 2 commits into
keycloak:mainfrom
edewit:fix-react-compiler-warnings-admin-ui
Open

edewit wants to merge 2 commits into
keycloak:mainfrom
edewit:fix-react-compiler-warnings-admin-ui

Conversation

@edewit
@edewit edewit commented Sep 17, 2026 •
Copy link
Copy Markdown
Contributor

Summary

  • Renames useRefreshTokens watch value to refreshTokensEnabled to avoid false-positive hook detection
  • Replaces useCallback(debounce(...)) with useMemo in UserSelect and IdentityProviderSelect
  • Stops mutating props/state in place in FlowRequirementDropdown, GroupPickerDialog, ClusteringPanel, and EditUser
  • Replaces delete on optional chaining with omit() in NewAttributeSettings and PartialImport
  • Removes manual i18n store mutation in RealmOverrides in favor of i18n.reloadResources()

Closes #52903

Follow-up

Remaining react-compiler/react-compiler warnings (primarily useRoutableTab hook wrappers) are tracked in #52900.

Copilot AI balanced review requested due to automatic review settings September 17, 2026 13:34
@edewit
edewit requested review from a team as code owners September 17, 2026 13:34
@edewit
edewit force-pushed the fix-react-compiler-warnings-admin-ui branch from dcf20af to 323baf3 Compare September 17, 2026 13:36
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.

🔵 Needs a closer look

reloadResources() may retain deleted translations in RealmOverrides.tsx.

Pull request overview

Updates the admin UI to address React Compiler warnings through immutable updates, safer deletion patterns, and memoized debounced handlers.

Changes:

  • Replaces in-place mutations with immutable updates.
  • Uses useMemo for debounced handlers.
  • Uses omit() for selective removal.
  • Refreshes localization resources after deletions.
File summaries
File Summary
js/apps/admin-ui/src/user/EditUser.tsx Uses immutable user updates.
js/apps/admin-ui/src/realm-settings/PartialImport.tsx Uses omit for role filtering.
js/apps/admin-ui/src/realm-settings/NewAttributeSettings.tsx Uses immutable required-scope updates.
js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx Reloads resources after deletion.
js/apps/admin-ui/src/organizations/IdentityProviderSelect.tsx Memoizes the debounced search handler.
js/apps/admin-ui/src/components/users/UserSelect.tsx Memoizes the debounced search handler.
js/apps/admin-ui/src/components/group/GroupPickerDialog.tsx Avoids mutating group selection state.
js/apps/admin-ui/src/clients/advanced/OpenIdConnectCompatibilityModes.tsx Renames the watched value.
js/apps/admin-ui/src/clients/advanced/ClusteringPanel.tsx Updates nodes immutably.
js/apps/admin-ui/src/authentication/components/FlowRequirementDropdown.tsx Updates flow requirements immutably.
Review details

Suppressed comments (1)

js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx:253

  • reloadResources() does not remove keys that are missing from the newly fetched bundle; i18next merges the reload into the existing resource store. Deleting a custom realm override that is not present in the theme therefore leaves the old value cached, so t(key) can continue returning the deleted translation. Clear/replace the affected resource bundle (and reload the relevant locale) instead of relying on the reload alone.
        await i18n.reloadResources();
  • Files reviewed: 10/10 changed files
  • Comments generated: 0
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Address eslint-plugin-react-compiler warnings across ten admin console
components by avoiding in-place mutations, using useMemo for debounced
handlers, and renaming watch values that look like hooks.

Closes keycloak#52903

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
@edewit
edewit force-pushed the fix-react-compiler-warnings-admin-ui branch from 323baf3 to 6f0199b Compare November 27, 2026 12:29
Copilot AI balanced review requested due to automatic review settings November 27, 2026 12:29
Copilot AI left a comment
< 8000 div class="timeline-comment-actions flex-shrink-0 d-flex flex-items-center">
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.

🟡 Changes recommended

Deleting a custom translation without a theme fallback leaves the old value available to t() until a page reload because reloadResources() merges messages instead of replacing the bundle.

1 open issue

Review effort: Balanced

: previous,
);
setAreAllRowsSelected(false);
await i18n.reloadResources();
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 15:08
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.

🔵 Needs a closer look

Deleted overrides can remain available after bundle merging, and raw realm names prevent cleanup for namespaces containing encoded characters.

1 open issue
2 previously missed issues

In code that hasn't changed since last review

Medium severity Deleted overrides persist because reloads shallow-merge the bundle

js/​apps/​admin-ui/​src/​realm-settings/​localization/​RealmOverrides.tsx:105

addResourceBundle(..., false, true) still shallow-merges into the existing bundle (upstream default branch), so a deleted override with no theme replacement remains available to t(). Remove and rebuild the bundle with the deleted keys excluded before reloading, so the reload can restore any theme defaults.

Medium severity Use the encoded realm namespace for bundle lookup

js/​apps/​admin-ui/​src/​realm-settings/​localization/​RealmOverrides.tsx:322

RealmContext.tsx:41–43 loads translations under encodeURIComponent(realm), but this passes the raw realm name to the resource-bundle lookup. For realm names containing spaces or other encoded characters, the helper cannot find the bundle and skips cleanup; pass the encoded namespace here.

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.

Fix react-compiler warnings: mutations, debounce, and delete patterns in admin UI

2 participants

0