diff --git a/.changeset/fix-scroll-state-container-query.md b/.changeset/fix-scroll-state-container-query.md new file mode 100644 index 000000000000..148062ab6c8c --- /dev/null +++ b/.changeset/fix-scroll-state-container-query.md @@ -0,0 +1,5 @@ +--- +"@biomejs/biome": patch +--- + +Fixed [#8842](https://github.com/biomejs/biome/issues/8842): The CSS formatter now correctly formats `@container scroll-state()` without adding an unwanted space between the function name and opening parenthesis. diff --git a/crates/biome_css_formatter/tests/specs/css/atrule/container.css b/crates/biome_css_formatter/tests/specs/css/atrule/container.css index 8c6335315999..2bb6fc4927db 100644 --- a/crates/biome_css_formatter/tests/specs/css/atrule/container.css +++ b/crates/biome_css_formatter/tests/specs/css/atrule/container.css @@ -66,3 +66,13 @@ inline-size @container ( WIDTH <= 150px ) { } @container ( 150px <= WIDTH ) { } + +@container scroll-state(scrolled: bottom) { } + +@container scroll-state(stuck: top) { } + +@container not scroll-state(stuck) { } + +@container card scroll-state(scrolled: bottom) { } + +@container scroll-state( scrolled: bottom ) { } diff --git a/crates/biome_css_formatter/tests/specs/css/atrule/container.css.snap b/crates/biome_css_formatter/tests/specs/css/atrule/container.css.snap index c98d06fca6e3..38cd1af5782e 100644 --- a/crates/biome_css_formatter/tests/specs/css/atrule/container.css.snap +++ b/crates/biome_css_formatter/tests/specs/css/atrule/container.css.snap @@ -75,6 +75,16 @@ inline-size @container ( WIDTH <= 150px ) { } @container ( 150px <= WIDTH ) { } +@container scroll-state(scrolled: bottom) { } + +@container scroll-state(stuck: top) { } + +@container not scroll-state(stuck) { } + +@container card scroll-state(scrolled: bottom) { } + +@container scroll-state( scrolled: bottom ) { } + ``` @@ -149,4 +159,15 @@ Trailing newline: true @container (150px <= WIDTH) { } +@container scroll-state(scrolled: bottom) { } + +@container scroll-state(stuck: top) { } + +@container not scroll-state(stuck) { +} + +@container card scroll-state(scrolled: bottom) { } + +@container scroll-state( scrolled: bottom ) { } + ``` diff --git a/crates/biome_css_parser/src/syntax/at_rule/container/mod.rs b/crates/biome_css_parser/src/syntax/at_rule/container/mod.rs index cd5e54c602ac..6ef43601de10 100644 --- a/crates/biome_css_parser/src/syntax/at_rule/container/mod.rs +++ b/crates/biome_css_parser/src/syntax/at_rule/container/mod.rs @@ -90,7 +90,7 @@ pub(crate) fn parse_container_at_rule_declarator(p: &mut CssParser) -> ParsedSyn let m = p.start(); p.bump(T![container]); - if !is_at_container_style_query_in_parens(p) { + if !is_at_container_style_query_in_parens(p) && !is_at_container_scroll_state_query(p) { let name = parse_custom_identifier(p, CssLexContext::Regular); // Because the name is optional, we have to indirectly check if it's // a CSS-wide keyword that can't be used. If it was required, we could