Skip to content

Commit b0b1198

Browse files
shedokanphilipp-spiessRobinMalfait
authored
Fix rtl/ltr to work with dir=auto (#14306)
This fixes the following issue #14305 by using `:dir()` --------- Co-authored-by: Philipp Spiess <[email protected]> Co-authored-by: Robin Malfait <[email protected]>
1 parent 7979474 commit b0b1198

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
- Skip candidates with invalid `theme()` calls ([#14437](https://github.com/tailwindlabs/tailwindcss/pull/14437))
2727
- Don't generate `inset-*` utilities for `--inset-shadow-*` and `--inset-ring-*` theme values ([#14447](https://github.com/tailwindlabs/tailwindcss/pull/14447))
2828
- Include `--default-transition-*` variables in `transition-*` utility output ([#14482](https://github.com/tailwindlabs/tailwindcss/pull/14482))
29+
- Ensure `rtl` and `ltr` variants work with `[dir=auto]` ([#14306](https://github.com/tailwindlabs/tailwindcss/pull/14306))
2930

3031
### Changed
3132

packages/tailwindcss/src/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ describe('plugins', () => {
19791979

19801980
expect(optimizeCss(compiled).trim()).toMatchInlineSnapshot(`
19811981
"@layer utilities {
1982-
.rtl\\:flex:where([dir="rtl"], [dir="rtl"] *) {
1982+
.rtl\\:flex:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
19831983
display: flex;
19841984
}
19851985
@@ -2489,7 +2489,7 @@ describe('@variant', () => {
24892489
),
24902490
).toMatchInlineSnapshot(`
24912491
"@layer utilities {
2492-
.rtl\\:flex:where([dir="rtl"], [dir="rtl"] *) {
2492+
.rtl\\:flex:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
24932493
display: flex;
24942494
}
24952495

packages/tailwindcss/src/variants.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ test('peer-*', async () => {
928928

929929
test('ltr', async () => {
930930
expect(await run(['ltr:flex'])).toMatchInlineSnapshot(`
931-
".ltr\\:flex:where([dir="ltr"], [dir="ltr"] *) {
931+
".ltr\\:flex:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) {
932932
display: flex;
933933
}"
934934
`)
@@ -937,7 +937,7 @@ test('ltr', async () => {
937937

938938
test('rtl', async () => {
939939
expect(await run(['rtl:flex'])).toMatchInlineSnapshot(`
940-
".rtl\\:flex:where([dir="rtl"], [dir="rtl"] *) {
940+
".rtl\\:flex:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
941941
display: flex;
942942
}"
943943
`)
@@ -2762,11 +2762,11 @@ test('variant order', async () => {
27622762
}
27632763
}
27642764
2765-
.ltr\\:flex:where([dir="ltr"], [dir="ltr"] *) {
2765+
.ltr\\:flex:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) {
27662766
display: flex;
27672767
}
27682768
2769-
.rtl\\:flex:where([dir="rtl"], [dir="rtl"] *) {
2769+
.rtl\\:flex:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
27702770
display: flex;
27712771
}
27722772

packages/tailwindcss/src/variants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,8 @@ export function createVariants(theme: Theme): Variants {
901901
staticVariant('portrait', ['@media (orientation: portrait)'], { compounds: false })
902902
staticVariant('landscape', ['@media (orientation: landscape)'], { compounds: false })
903903

904-
staticVariant('ltr', ['&:where([dir="ltr"], [dir="ltr"] *)'])
905-
staticVariant('rtl', ['&:where([dir="rtl"], [dir="rtl"] *)'])
904+
staticVariant('ltr', ['&:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *)'])
905+
staticVariant('rtl', ['&:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *)'])
906906

907907
staticVariant('dark', ['@media (prefers-color-scheme: dark)'], { compounds: false })
908908

0 commit comments

Comments
 (0)