feat: remove dir polyfill [CSS-222]#4014
Conversation
🦋 Changeset detectedLatest commit: fd04a38 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
File metricsSummaryTotal size: 1.43 MB*
File change detailsaccordion
actionbutton
assetlist
breadcrumb
calendar
colorarea
colorloupe
colorslider
colorwheel
combobox
menu
pagination
popover
progressbar
radio
slider
steplist
switch
table
tooltip
treeview
* An ASCII character in UTF-8 is 8 bits or 1 byte. |
📚 Branch previewPR #4014 has been deployed to Azure Blob Storage: https://spectrumcss.z13.web.core.windows.net/pr-4014/index.html. |
|
Manual VRT compare: https://www.chromatic.com/review?appId=64762974a45b8bc5ca1705a2&number=35&type=unlinked&view=activity It uncovered only 1 diff which seems to have just been a test blip off spectrum-two's last baseline. |
9b639c3 to
6e05e55
Compare
6e05e55 to
3f7c23e
Compare
7b7cd96 to
dddadbe
Compare
98fb718 to
57c4d2a
Compare
marissahuysentruyt
left a comment
There was a problem hiding this comment.
Checked all keyboard navigation and RTL content flow for each component. 👍 I noted some regressions with calendar and switch in RTL. I'm not sure if this is the PR to fix those, or if we wanted to make tickets for them.
For the compare, I did get infield progress circle surfaced. Looks like it's just white space changes, but want to mention it just in case.
| "[dir=\"rtl\"] .spectrum-Tooltip--bottom-start .spectrum-Tooltip-tip", | ||
| "[dir=\"rtl\"] .spectrum-Tooltip--end .spectrum-Tooltip-tip", | ||
| "[dir=\"rtl\"] .spectrum-Tooltip--end-bottom .spectrum-Tooltip-tip", | ||
| "[dir=\"rtl\"] .spectrum-Tooltip--end-bottom.is-open", | ||
| "[dir=\"rtl\"] .spectrum-Tooltip--end-top .spectrum-Tooltip-tip", | ||
| "[dir=\"rtl\"] .spectrum-Tooltip--end-top.is-open", | ||
| "[dir=\"rtl\"] .spectrum-Tooltip--end.is-open", |
| ".spectrum-Calendar-title", | ||
| ".spectrum-Calendar:dir(rtl)", | ||
| "[dir=\"rtl\"] .spectrum-Calendar" | ||
| ".spectrum-Calendar:dir(rtl)" |
There was a problem hiding this comment.
Do we need some additional CSS to fix the chevron from flipping? In the video, if I click the action buttons to advance the month, the chevron flips when the button is active.
Screen.Recording.2025-07-28.at.2.05.57.PM.mov
I think it's because of this transform:
spectrum-css/components/calendar/index.css
Line 180 in cc65f04
I don't think we can remove that line, but maybe we add the .spectrum-Calendar-prevMonth:active and
.spectrum-Calendar-nextMonth:active selectors, to the block? You might know of a more elegant solution.
There was a problem hiding this comment.
Yes, great call-out. Let me take a look. I think this is the perfect place to make that update since this is a breaking change PR specifically to allow these styles to be used without the [dir] attribute polyfill.
| ".spectrum-Switch:hover .spectrum-Switch-switch:before", | ||
| ".spectrum-Switch:hover ~ .spectrum-Switch-label", | ||
| "[dir=\"rtl\"] .spectrum-Switch--active .spectrum-Switch-input:not(:disabled):checked + .spectrum-Switch-switch:before", | ||
| "[dir=\"rtl\"] .spectrum-Switch-input:checked + .spectrum-Switch-switch:before", |
There was a problem hiding this comment.
We might have to address the switch too. When I select the switch in RTL, the position of the .spectrum-Switch-switch:before element isn't quite right. I haven't dug into where this is coming from though...
There was a problem hiding this comment.
This one looks to already be in the spectrum-two branch, so maybe this is a bug. I can make a ticket for it!
57c4d2a to
fd04a38
Compare
marissahuysentruyt
left a comment
There was a problem hiding this comment.
looks great!
fd04a38 to
e211963
Compare
Description
This PR removes the
dirattribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. Thedirattribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs.Breaking change: This is a breaking change only to those relying on the
dirattribute being present for styling, however, the:dirpseudo will correctly inherit values from their containers. To correctly determine thedirvalue of a node using JavaScript, you can usegetComputedStyle(node).direction.Components affected: This change affects 22 components that previously relied on the
dirpolyfill:Technical changes:
"dir-pseudo-class": { preserve: true }from PostCSS config[dir="rtl"]selectorsHow and where has this been tested?
Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.
Validation steps
Test RTL layout in accordion component: @marissahuysentruyt
Test RTL layout in breadcrumb component: @marissahuysentruyt
Test RTL layout in calendar component: @marissahuysentruyt
Test RTL layout in pagination component: @marissahuysentruyt
Test RTL layout in tabs component: @marissahuysentruyt
Test that
getComputedStyle(node).directionreturns correct values: @marissahuysentruytdir="ltr"anddir="rtl"attributesgetComputedStyle(node).directionreturns "ltr" and "rtl" respectivelyRun component comparison:
yarn component:compareto verify changes against published versions[dir="rtl"]selectors were removed:dir(rtl)selectors remain intactRegression testing
Validate:
Screenshots
No visual changes expected - this is a technical cleanup removing polyfill code that is no longer needed.
To-do list