Skip to content

fix: Icons motion perf issue - #5161

Merged
georgylobko merged 1 commit into
mainfrom
fix/icons-motion-perf-issue
Oct 20, 2026
Merged

georgylobko merged 1 commit into
mainfrom
fix/icons-motion-perf-issue

Conversation

@georgylobko

@georgylobko georgylobko commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Description

Removes :has() from the one-theme icon hover-motion CSS. Its selectors were evaluated against every motion trigger on each style recalc and DOM insert, which slowed down pages with many triggers or frequent DOM updates. Focus motion now uses plain :focus-visible selectors. Action card, where the focused button does not contain the icon, uses a new delegated-focus trigger: :focus-within, gated on the data-awsui-focus-visible body attribute so only keyboard focus plays it. The cancel rule for icons with only part motion no longer checks the parts with :has(). Tests assert that the compiled motion CSS has no :has().

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

'aria-disabled': disabled || undefined,
// The hover region is the whole card (see the root element); focusing
// the inner control also plays the motion.
'data-awsui-motion-trigger': 'focus',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's dead now. Only the old root :has() looked for it, and the root now uses :focus-within. The other focus rule needs the icon inside the focused element, which never happens here, since the button doesn't contain the icon

data-awsui-motion-trigger="hover"
// Keyboard focus on the nested header or overlay button, which does not contain the icon,
// also plays the motion.
data-awsui-motion-trigger="hover delegated-focus"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

hover plays the motion while the pointer is over the card. delegated-focus plays it when keyboard focus is inside the card, because the focused button doesn't contain the icon

@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.73%. Comparing base (af861d1) to head (448082a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5161   +/-   ##
=======================================
  Coverage   97.72%   97.73%           
=======================================
  Files         995      996    +1     
  Lines       32129    32152   +23     
  Branches    11851    11859    +8     
=======================================
+ Hits        31399    31424   +25     
- Misses        684      722   +38     
+ Partials       46        6   -40     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@georgylobko
georgylobko marked this pull request as ready for review October 20, 2026 11:41
@georgylobko
georgylobko requested a review from a team as a code owner October 20, 2026 11:41
@georgylobko
georgylobko requested review from mxschll and taheramr and a balanced review from Copilot and removed request for a team and taheramr October 20, 2026 11:41

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

The focused selector changes match existing focus and icon-rendering contracts, with regression coverage and no identified blocking issues.

No open issues 🎉

What changed in this PR

Removes costly :has() selectors from icon motion CSS while preserving keyboard-focus motion, including action cards.

Changes:

  • Uses direct focus selectors and delegated focus for action cards.
  • Simplifies cancellation of whole-icon motion for icons with part-specific animations.
  • Adds regression assertions for selectors, icon parts, and action-card wiring.
File Description
src/​icon/​hover-motion.scss Replaces :has() selectors and simplifies motion cancellation.
src/​icon/​__tests__/​icon-hover-motion.test.ts Checks focus selectors, absence of :has(), and animated icon parts.
src/​action-card/​internal.tsx Enables delegated-focus motion on the card root.
src/​action-card/​__tests__/​action-card.test.tsx Verifies delegated-focus wiring for both button layouts.

Review effort: Balanced

@mxschll

mxschll commented Oct 20, 2026

Copy link
Copy Markdown
Member

LGTM. One thing: we use :has throughout the repo, e.g. here. The scope is probably smaller as it's only one component and not all icons. Still, should we refactor these as well in the future?

@georgylobko
georgylobko added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit d57c87f Oct 20, 2026
71 checks passed
@georgylobko
georgylobko deleted the fix/icons-motion-perf-issue branch October 20, 2026 13:00

This branch was successfully deployed

3 active deployments
dev-pages-react16 — 448082a2 Deployed Oct 20, 2026 by georgylobko via deploy (React 16) / deploy #2863
dev-pages-react18 — 448082a2 Deployed Oct 20, 2026 by georgylobko via deploy (React 18) / deploy #2863
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.

3 participants