Skip to content

fix(ui): reset TierCard selectedTier on close to prevent stale radio state - #33115

Merged
Rohit0301 merged 6 commits into
mainfrom
TierCard-Stale-State-Bug
Sep 10, 2026
Merged

Rohit0301 merged 6 commits into
mainfrom
TierCard-Stale-State-Bug

Conversation

@Rohit0301

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #

Two bugs in TierCard caused the tier radio button to show stale state:

  • Bug A (cancel-stale): cancelling a tier change left the unsaved selection active on reopen — handleOpenChange reset selectedTier on close, but the old inline onOpenChange didn't.
  • Bug B (save-stale): after a successful save, the old tier was shown on reopen because the close handler closed over a stale currentTier before React propagated the updated prop from the entity context.

Fix: extracted handleOpenChange that resets selectedTier → currentTier on every close, and added a useEffect([currentTier]) guard that re-syncs when the prop updates while the popover is closed (covers the save-stale race).

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • Cancelling a tier change: on reopen the radio shows the persisted tier, not the cancelled one.
  • Saving a new tier: on reopen the radio shows the newly saved tier, not the stale previous one.

Unit tests

  • Added openmetadata-ui/src/main/resources/ui/src/components/common/TierWidget/TierWidget.test.tsx — covers both bugs via direct onOpenChange simulation and prop rerender.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Added openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/TierWidget.spec.ts — E2E regression spec covering both stale-state scenarios on a real table entity.

Manual testing performed

  1. Set Tier1 on a table entity via the tier widget.
  2. Reopened the widget, selected Tier2, cancelled — verified Tier1 still shown on next reopen.
  3. Saved Tier2 — verified Tier2 shown on next reopen (not stale Tier1).

UI screen recording / screenshots:

Not applicable — logic-only change; no visual layout changes.

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.
  • For JSON Schema changes: N/A.
  • For UI changes: no layout changes, no recording needed.
  • I have added tests (unit + Playwright) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

…state

Two bugs caused the tier radio button to show stale state:
- Bug A: cancelling a tier change left the cancelled tier selected on reopen
- Bug B: after a successful save, the old tier was shown on reopen because
  handleOpenChange closed over a stale currentTier before React propagated
  the updated prop

Fix: extract handleOpenChange to reset selectedTier to currentTier on every
close, and add a useEffect([currentTier]) guard that re-syncs when the prop
updates while the popover is closed (covers the save-stale race).

Adds unit tests (TierWidget.test.tsx) and a Playwright E2E spec
(TierWidget.spec.ts) covering both scenarios.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 553 → 555
- 2 added, 0 removed, 7 changed spec-list

New source→spec entries:
  openmetadata-ui/src/main/resources/ui/src/components/common/Table/TableV2.tsx
  openmetadata-ui/src/main/resources/ui/src/components/common/TierCard/TierCard.tsx

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/src/components/DataAssets/DataAssetsHeader/DataAssetsHeader.component.tsx
  openmetadata-ui/src/main/resources/ui/src/components/DataQuality/TestSuite/TestSuitePipelineTab/TestSuitePipelineTab.component.tsx
  openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryTermTab/GlossaryTermTab.component.tsx
  openmetadata-ui/src/main/resources/ui/src/components/Settings/Services/Ingestion/IngestionListTable/IngestionListTable.tsx
  openmetadata-ui/src/main/resources/ui/src/components/common/TierWidget/TierWidget.tsx
  openmetadata-ui/src/main/resources/ui/src/generated/entity/data/table.ts
  openmetadata-ui/src/main/resources/ui/src/generated/entity/data/topic.ts

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added the UI UI specific issues label Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@Rohit0301 Rohit0301 self-assigned this Sep 10, 2026
@Rohit0301 Rohit0301 added the safe to test Add this label to run secure Github workflows on PRs label Sep 10, 2026
Rohit0301 and others added 3 commits September 10, 2026 12:44
…-sync

The useEffect that re-syncs selectedTier on currentTier change was guarding
with !popoverProps?.open, but uncontrolled usages (no popoverProps) have
open === undefined (always falsy), so the reset fired mid-edit, silently
discarding the user's in-progress selection.

Fix: add isOpen state updated in handleOpenChange so the guard works for
both controlled and uncontrolled usages. Also adds isOpen to the useEffect
dependency array to satisfy react-hooks/exhaustive-deps.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 2 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 2 warning(s) across 1 changed file(s).

Count Rule
1 openmetadata-imports/no-circular-imports
1 react-hooks/exhaustive-deps
All findings
Location Rule Message
🟡 src/components/common/TierCard/TierCard.tsx:37:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/components/common/TierCard/TierCard.tsx:124:6 react-hooks/exhaustive-deps React Hook useEffect has missing dependencies: 'getTierData' and 'tierCardData.length'. Either include them or remove the dependency array.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 70%
70.51% (95407/135307) 55.04% (56457/102567) 56.44% (18858/33410)

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants