Repository navigation
refactor: Refactors token to use internal button for dismiss - #5189
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5189 +/- ##
==========================================
- Coverage 97.73% 97.73% -0.01%
==========================================
Files 998 998
Lines 32291 32287 -4
Branches 11941 11939 -2
==========================================
- Hits 31561 31557 -4
+ Misses 724 685 -39
- Partials 6 45 +39 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The refactor changes pressed-state dismiss colors for unstyled and partially styled tokens.
1 open issue
What changed in this PR
Refactors token dismissal to use the shared internal button, reducing custom implementation ahead of styling v2 support.
Changes:
- Replaces the custom dismiss button with
InternalButton. - Maps token dismiss styles to button styles and isolates inherited styling properties.
- Updates style, motion, and analytics tests for the shared implementation.
| File | Description |
|---|---|
src/token/styles.tsx |
Maps dismiss styles to the button style API. |
src/token/styles.scss |
Preserves token-specific button geometry and focus styling. |
src/token/internal.tsx |
Passes token styles to the dismiss button. |
src/token/dismiss-button.tsx |
Replaces custom markup with InternalButton. |
src/token/__tests__/token.test.tsx |
Updates motion attribute expectations. |
src/token/__tests__/styles.test.tsx |
Tests dismiss style mapping and state precedence. |
src/token/__tests__/analytics-metadata.test.tsx |
Checks exact dismiss analytics metadata. |
src/token/__tests__/__snapshots__/styles.test.tsx.snap |
Removes dismiss styles from root snapshots. |
src/internal/styles/forms/mixins.scss |
Adds a reset for inherited button styling properties. |
Review effort: Balanced
| #{custom-props.$styleFocusRingBoxShadow}: 0 0 0 | ||
| var(#{custom-props.$styleFocusRingBorderWidth}, foundation.$box-shadow-focused-width) | ||
| var(#{custom-props.$styleFocusRingBorderColor}, awsui.$color-border-item-focused); | ||
| @include styles.reset-v1-button-styles; |
There was a problem hiding this comment.
Good comment. The new behaviour is indeed different from the previous custom dismiss button implementation. At the same time - it is consistent with icon button's default implementation - so also reproducible in standalone buttons or e.g. in Alert/Flashbar dismiss. I believe we should keep it therefore for consistency, and if we want a design change - apply it for all icon buttons, not just token dismiss.

Description
Makes token component use internal button instead of a custom dismiss button implementation. The change is done in preparation of adding styling v2 support: it is not a requirement, but it helps to make styling implementation simpler.
How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.