Skip to content

Commit 6dd4c33

Browse files
Include :open in the open variant (#15349)
Update the `open` variant to addtionally match the new `:open` pseudo class. See spec at https://drafts.csswg.org/selectors-4/#open-state See Chromium intent to ship: https://groups.google.com/a/chromium.org/g/blink-dev/c/Pdo4oOXYKcA `:open` matches open `<details>` and `<dialog>` elements (already covered by [open]), but also matches select elements with their picker open and inputs with their picker open. Thanks to `:is()` taking a forgiving selector list, this is safe to add even with limited browser support. Co-authored-by: Robin Malfait <[email protected]>
1 parent a707fed commit 6dd4c33

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Target `:open` in existing `open` variant ([#15349](https://github.com/tailwindlabs/tailwindcss/pull/15349))
13+
1014
### Fixed
1115

1216
- Remove invalid `min-w/h-none` utilities ([#15845](https://github.com/tailwindlabs/tailwindcss/pull/15845))

packages/tailwindcss/src/variants.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ test('target', async () => {
233233

234234
test('open', async () => {
235235
expect(await run(['open:flex', 'group-open:flex', 'peer-open:flex'])).toMatchInlineSnapshot(`
236-
".group-open\\:flex:is(:where(.group):is([open], :popover-open) *), .peer-open\\:flex:is(:where(.peer):is([open], :popover-open) ~ *), .open\\:flex:is([open], :popover-open) {
236+
".group-open\\:flex:is(:where(.group):is([open], :popover-open, :open) *), .peer-open\\:flex:is(:where(.peer):is([open], :popover-open, :open) ~ *), .open\\:flex:is([open], :popover-open, :open) {
237237
display: flex;
238238
}"
239239
`)
@@ -1473,7 +1473,7 @@ test('not', async () => {
14731473
display: flex;
14741474
}
14751475
1476-
.not-open\\:flex:not([open], :popover-open) {
1476+
.not-open\\:flex:not([open], :popover-open, :open) {
14771477
display: flex;
14781478
}
14791479
@@ -2214,7 +2214,7 @@ test('variant order', async () => {
22142214
display: flex;
22152215
}
22162216
2217-
.first\\:flex:first-child, .last\\:flex:last-child, .only\\:flex:only-child, .odd\\:flex:nth-child(odd), .even\\:flex:nth-child(2n), .first-of-type\\:flex:first-of-type, .last-of-type\\:flex:last-of-type, .only-of-type\\:flex:only-of-type, .visited\\:flex:visited, .target\\:flex:target, .open\\:flex:is([open], :popover-open), .default\\:flex:default, .checked\\:flex:checked, .indeterminate\\:flex:indeterminate, .placeholder-shown\\:flex:placeholder-shown, .autofill\\:flex:autofill, .optional\\:flex:optional, .required\\:flex:required, .valid\\:flex:valid, .invalid\\:flex:invalid, .in-range\\:flex:in-range, .out-of-range\\:flex:out-of-range, .read-only\\:flex:read-only, .empty\\:flex:empty, .focus-within\\:flex:focus-within {
2217+
.first\\:flex:first-child, .last\\:flex:last-child, .only\\:flex:only-child, .odd\\:flex:nth-child(odd), .even\\:flex:nth-child(2n), .first-of-type\\:flex:first-of-type, .last-of-type\\:flex:last-of-type, .only-of-type\\:flex:only-of-type, .visited\\:flex:visited, .target\\:flex:target, .open\\:flex:is([open], :popover-open, :open), .default\\:flex:default, .checked\\:flex:checked, .indeterminate\\:flex:indeterminate, .placeholder-shown\\:flex:placeholder-shown, .autofill\\:flex:autofill, .optional\\:flex:optional, .required\\:flex:required, .valid\\:flex:valid, .invalid\\:flex:invalid, .in-range\\:flex:in-range, .out-of-range\\:flex:out-of-range, .read-only\\:flex:read-only, .empty\\:flex:empty, .focus-within\\:flex:focus-within {
22182218
display: flex;
22192219
}
22202220

packages/tailwindcss/src/variants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ export function createVariants(theme: Theme): Variants {
681681
// State
682682
staticVariant('visited', ['&:visited'])
683683
staticVariant('target', ['&:target'])
684-
staticVariant('open', ['&:is([open], :popover-open)'])
684+
staticVariant('open', ['&:is([open], :popover-open, :open)'])
685685

686686
// Forms
687687
staticVariant('default', ['&:default'])

0 commit comments

Comments
 (0)