Skip to content

Fixes #37771: clear React Aria controlled props with null, and lint for it - #37772

Merged
chirag-madlani merged 3 commits into
mainfrom
chirag-madlani/qb-select-clear-loop
Nov 13, 2026
Merged

chirag-madlani merged 3 commits into
mainfrom
chirag-madlani/qb-select-clear-loop

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #37771

Clearing the value of an async query builder select in one go (Cmd+Delete, or select-all + Delete) crashed the page with "Maximum update depth exceeded".

Cause. OMSelectWidget passed selectedKey={undefined} to Select.ComboBox when the value was empty. React Aria treats undefined as uncontrolled, so the moment the value emptied the component took over its own selection, and its state and the query builder's kept correcting each other until React gave up. null is React Aria's controlled empty value.

Same pattern elsewhere. I swept OpenMetadata UI, core components and Collate UI for controlled props (selectedKey, selectedKeys, inputValue, isOpen, isSelected, expandedKeys, value on React Aria fields) that can flip to undefined. This PR fixes the OpenMetadata ones:

File Was Now
utils/queryBuilderWidgets/OMSelectWidget.tsx selectedKey={… : undefined} : null (the crash)
utils/queryBuilderWidgets/OMFieldSelect.tsx selectedKey={selectedKey ?? undefined} ?? null
components/common/FormBuilderV1/widgets/CoreRadioWidget.tsx value={… ? undefined : String(value)} ? null (matches CoreSelectWidget)
components/Settings/Services/ServiceAttributes/ServiceAttributesCard.tsx value={draft.environment} (optional field) ?? null
components/Settings/Services/Ingestion/Ingestion.component.tsx selectedKey={subTab} (route param, absent on the default sub-tab) subTab ?? ServiceAgentSubTabs.METADATA

CopyToClipboardButton's isOpen={hasCopied || undefined} flips on purpose (it forces the tooltip open after a copy and otherwise leaves hover to React Aria), so it keeps the pattern with the reason and a line-level disable.

Guard. New ESLint rule openmetadata-ui-patterns/no-undefined-controlled-prop (error) fails a JSX controlled prop on a component whose expression falls back to a literal undefined / void 0 (ternary branch, ??, ||). After this PR it reports zero findings across OpenMetadata UI and core components. It cannot see a variable whose type includes undefined (two of the fixes above were that shape), so the record states the rule for review.

Decision record: ADR:2026-11-13-react-aria-controlled-props-are-cleared-with-null-not-undefined, with a one-line pointer in .claude/rules/component-library.md.

Not changed: the core DatePicker / DateRangePicker hand value straight to useControlledState, so a caller passing undefined would flip them too. No caller does today, and coercing undefined → null inside the wrapper would break callers that are deliberately uncontrolled.

Type of change:

  • Bug fix

High-level design:

N/A — small fixes plus one lint rule.

Tests:

Use cases covered

  • Clearing an async select value no longer crashes; a new value can be searched and picked.
  • Clearing and switching a query builder field works.
  • Service Agents sub-tabs: opening the tab selects Metadata; Metadata ↔ Collate AI switches and browser Back work.

Unit tests

  • I added unit tests for the new/changed logic.
  • OMSelectWidget.test.tsx: keeps the async select controlled when its value is cleared — fails on the old code, passes with the fix.
  • eslint-rules/openmetadata-ui-patterns.test.mjs: 6 valid / 5 invalid cases for the new rule (58/58 in the file pass).
  • Jest over utils/queryBuilderWidgets, Settings/Services/Ingestion, Settings/Services/ServiceAttributes, common/FormBuilderV1, common/CopyToClipboardButton: all pass except IngestionListTable.test.tsx, which fails identically on unmodified main in my checkout (Cannot find module '@tiptap/react/menus', a local install gap).
  • ESLint on every changed file: 0 errors (only pre-existing exhaustive-deps warnings). check_decision_records.py: clean.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Impacted specs not run locally yet.

Visual regression baselines

  • Not applicable (no rendering change).

Manual testing performed

Collate UI dev server on latest main against a local 2.0.0-SNAPSHOT server with sample data:

  1. AI Automations → Edit → scope rule Service Is elasticsearch_sample. Select all + Delete in the value: before, "Maximum update depth exceeded"; after, the field clears, sample lists services, picking sample_airflow updates the count to 12 assets.
  2. Same editor, Add New Field → clear the field and pick Tier: switches with no error.
  3. sample_data service → Agents: Metadata selected on open, three Metadata ↔ Collate AI round trips, Back returns to Summary; no page errors or controlled/uncontrolled warnings.
    CoreRadioWidget and ServiceAttributesCard are covered by their unit suites only.

UI screen recording:

Not applicable — bug fix with no new UI. Before/after clips of step 1 are attached in a comment below.

before.mp4
after.mp4

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Decision check: adds docs/decisions/2026-11-13-react-aria-controlled-props-are-cleared-with-null-not-undefined.md.
  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code

…ared

OMSelectWidget passed selectedKey={undefined} to Select.ComboBox for an
empty value, which hands the selection to React Aria. Clearing the input
then looped between its state and the query builder's until React threw
"Maximum update depth exceeded". Pass null, as the sync Select already does.
@chirag-madlani
chirag-madlani requested a review from a team as a code owner November 13, 2026 12:15
@chirag-madlani
chirag-madlani requested review from karanh37 and a balanced review from Copilot November 13, 2026 12:15
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…or it

The same undefined fallback that crashed the async select also sat on the
query builder field select, the form radio widget, the service environment
select and the service agents sub-tabs. Each now passes its empty controlled
value. A new ESLint rule, openmetadata-ui-patterns/no-undefined-controlled-prop,
fails a literal undefined fallback on a controlled prop, and the decision
record states the rule for the cases the lint cannot see.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 13:08
@chirag-madlani chirag-madlani changed the title Fixes #37771: keep the async query builder select controlled when cleared Fixes #37771: clear React Aria controlled props with null, and lint for it Nov 13, 2026

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 13, 2026 13:33

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Changing React Aria empty-value handling across selects, tabs, and form fields, with a new lint rule, could alter UI state when controls are cleared.

Fixes the "Maximum update depth exceeded" crash when clearing an async query builder select by passing null instead of undefined to React Aria controlled props, and adds an ESLint rule to guard against the pattern. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@chirag-madlani chirag-madlani added the To release Will cherry-pick this PR into the release branch label Nov 13, 2026
@chirag-madlani
chirag-madlani merged commit 8a03f70 into main Nov 13, 2026
54 of 56 checks passed
@chirag-madlani
chirag-madlani deleted the chirag-madlani/qb-select-clear-loop branch November 13, 2026 14:05
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.0 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

chirag-madlani added a commit that referenced this pull request Nov 13, 2026
…or it (#37772) (#37781)

* Fixes #37771: keep the async query builder select controlled when cleared

OMSelectWidget passed selectedKey={undefined} to Select.ComboBox for an
empty value, which hands the selection to React Aria. Clearing the input
then looped between its state and the query builder's until React threw
"Maximum update depth exceeded". Pass null, as the sync Select already does.

* Fixes #37771: clear React Aria controlled props with null, and lint for it

The same undefined fallback that crashed the async select also sat on the
query builder field select, the form radio widget, the service environment
select and the service agents sub-tabs. Each now passes its empty controlled
value. A new ESLint rule, openmetadata-ui-patterns/no-undefined-controlled-prop,
fails a literal undefined fallback on a controlled prop, and the decision
record states the rule for the cases the lint cannot see.

* Format the no-undefined-controlled-prop rule and its tests

(cherry picked from commit 8a03f70)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clearing an async query builder select value crashes with "Maximum update depth exceeded"

3 participants