Skip to content

fix(Tabs): don't disable accent transition when re-measuring on title/actions change - #12726

Open
logonoff wants to merge 1 commit into
patternfly:mainfrom
logonoff:fix-tabs-accent-animation-react19
Open

logonoff wants to merge 1 commit into
patternfly:mainfrom
logonoff:fix-tabs-accent-animation-react19

Conversation

@logonoff

@logonoff logonoff commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

What: Closes #12725

Additional issues: n/a

Root cause

Tab re-measures the current-tab accent whenever the title/actions prop identity changes, and passed true to setAccentStyles, which applies pf-m-initializing-accent (--pf-v6-c-tabs--link-accent--TransitionDuration: 0):

useEffect(() => {
  setAccentStyles(true);
}, [title, actions]);

React element props get a new identity on every parent render, so with the documented inline usage (title={<TabTitleText>…</TabTitleText>}) this effect fires on every render, including every tab switch.

  • React 18: the effect flushed after the componentDidUpdate accent update had already committed, so the transition ran and the later re-measure computed identical values — a visual no-op.
  • React 19: pending passive effects are flushed before rendering the nested sync update from componentDidUpdate, so isInitializingAccent: true lands in the same commit as the new accent position values. The only style recalc sees the new position with transition duration 0, so the underline jumps instead of animating.

Change

The title/actions re-measure no longer applies the initializing flag:

useEffect(() => {
  setAccentStyles();
}, [title, actions]);
  • Spurious re-runs (every parent re-render) become harmless: they queue the same accent values componentDidUpdate already queued, so nothing visually changes.
  • The initial-mount measurement still uses the flag via componentDidMount, so the underline still appears in place on first render (existing mount tests are unchanged).
  • Behavior note: a genuine title/actions content change now animates the accent to its new position, consistent with the pf-m-animate-current design, instead of jumping.

Verification

  • New regression test Does not render with class pf-m-initializing-accent when a controlled tab is selected fails on main and passes with this change. It renders controlled tabs with inline title elements, selects a tab, and asserts via MutationObserver that pf-m-initializing-accent never transiently appears.
  • All Tabs tests pass: 101 tests / 6 suites, snapshots unchanged.
  • Verified in a browser against this branch's compiled sources with React 19.3.1 using the reproduction from Bug - Tabs - Tab underline microanimation requires workaround under React 19 #12725: with the patch, the inline-titles demo's underline animates (sampled translate 0 → 52.5 → 81.2 → 91px at 40/80/160ms after click) instead of jumping, matching the memoized-titles workaround demo, and pf-m-initializing-accent no longer appears during selection.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a visual issue in controlled tabs where an initializing accent style could reappear while switching tabs. The style now stays cleared after initialization, helping tabs maintain a consistent appearance during selection.

…/actions change

Tab re-measures the current-tab accent whenever the title/actions prop
identity changes, and passed `true` to setAccentStyles, which applies
pf-m-initializing-accent (accent transition duration 0). React element
props get a new identity on every parent render, so with the documented
inline usage (title={<TabTitleText>...</TabTitleText>}) this effect fires
on every render, including every tab switch.

On React 18 the effect flushed after the componentDidUpdate accent update
had already committed, so the transition ran and the later re-measure was a
visual no-op. React 19 flushes pending passive effects before rendering the
nested update from componentDidUpdate, so isInitializingAccent lands in the
same commit as the new accent position values and the underline jumps
instead of animating (fixes patternfly#12725).

Re-measure without the initializing flag instead. Spurious re-runs become
harmless: they queue the same accent values componentDidUpdate already
queued, so nothing visually changes. The initial-mount measurement keeps
using the flag via componentDidMount, so the underline still appears in
place on first render. As a side effect, a genuine title/actions change now
animates the accent to its new position, consistent with the
pf-m-animate-current design.

Assisted-by: Opencode glm-5-3
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Tab effect now calls setAccentStyles without the former true argument. A controlled Tabs regression test checks that the initializing-accent class does not reappear when selecting another tab.

Changes

Tabs accent behavior

Layer / File(s) Summary
Update accent effect and verify tab selection
packages/react-core/src/components/Tabs/Tab.tsx, packages/react-core/src/components/Tabs/__tests__/Tabs.test.tsx
The effect calls setAccentStyles without the former argument. The controlled Tabs test observes class changes during selection and asserts that the initializing-accent class does not reappear.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: thatblindgeye, gabipodolnikova

Merge Risk: Minimal · up to a89b4

This change lets the Tabs underline animation run when inline title elements are recreated on render under React 19. No merge-blocking risk was found, and a regression test covers the behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the Tabs component and the core change: the re-measurement on title/actions change no longer disables the accent transition. The raw summary confirms that TabBase now calls setAccentSt…
Linked Issues check Passed Issue #12725 requires the Tabs underline microanimation to run with inline TabTitleText elements under React 19, without consumer memoization. The reviewed diff for packages/react-core/src/components/…
Out of Scope Changes check Passed Whole-PR diff against the merge base contains one source change in Tab.tsx (one line) and test additions in Tabs.test.tsx (about 32 lines, including a waitFor import and the controlled-tab regression …
Full details: Title check

Explanation

The title names the Tabs component and the core change: the re-measurement on title/actions change no longer disables the accent transition. The raw summary confirms that TabBase now calls setAccentStyles() without the initializing flag in the title/actions effect, and the objectives describe the same intent. The title is specific and matches the changeset. The conventional-commit prefix 'fix(Tabs):' is used, and the subject is concise.

Full details: Linked Issues check

Explanation

Issue #12725 requires the Tabs underline microanimation to run with inline TabTitleText elements under React 19, without consumer memoization. The reviewed diff for packages/react-core/src/components/Tabs/Tab.tsx changes one line: the effect keyed on [title, actions] now calls setAccentStyles() instead of setAccentStyles(true). This removes the pf-m-initializing-accent flag from the re-measure that fires on every parent render with inline title elements. The initial-mount measurement still uses the flag through componentDidMount, so first-render placement is unchanged. The PR adds a controlled-tab regression test (per the PR summary) that asserts pf-m-initializing-accent does not appear during tab selection. I did not read the test file, and I did not reproduce the claimed fail-on-main result. That result is author-reported. The code change addresses the root cause described in the issue. No non-coding requirements apply.

Full details: Out of Scope Changes check

Explanation

Whole-PR diff against the merge base contains one source change in Tab.tsx (one line) and test additions in Tabs.test.tsx (about 32 lines, including a waitFor import and the controlled-tab regression test). The source change is the direct fix for #12725. The test change supports that fix. The raw summary reports no changes to exported or public declarations. No unrelated changes were identified. The snapshot claim (unchanged) was not independently verified.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9f372d2f-11a1-4db4-a550-3c456017f6c8
Commits

Reviewing files that changed from the base of the PR and between 5276afd and a89b4f2.

Files selected for processing: 2

  • packages/react-core/src/components/Tabs/Tab.tsx
  • packages/react-core/src/components/Tabs/__tests__/Tabs.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@patternfly-build

patternfly-build commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

This branch has not been deployed

No deployments
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.

Bug - Tabs - Tab underline microanimation requires workaround under React 19

2 participants