question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSS Grid template formatting is broken when adding track size after line names

See original GitHub issue

Description

grid-template gets formatted as one line when adding track sizes after line names

Input

The code looked like this before beautification:

.grid {
    grid-template:
        "top-bar top-bar" 100px
        "left-bar center" 100px 
}

Expected Output

The code should have looked like this after beautification:

.grid {
    grid-template:
        "top-bar top-bar" 100px
        "left-bar center" 100px 
}

Actual Output

The code actually looked like this after beautification:

.grid {
    grid-template:
        "top-bar top-bar"100px "left-bar center"100px
}

Steps to Reproduce

  1. create a selector with a grid-template declaration in it
  2. add a value that contains line names and track sizes (as stated in the example above)
  3. format the document.

Also try it with a longer input:

grid-template:
        "top-bar center center center center center top-bar" 100px 
      	"left-bar center center center center center" 100px 
        / 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px;

The result looks like this:

    grid-template:
        "top-bar center center center center center top-bar"100px "left-bar center center center center center"100px / 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px 10px;

Environment

OS: Windows

Settings

{
  "indent_size": "4",
  "indent_char": " ",
  "max_preserve_newlines": "5",
  "preserve_newlines": true,
  "keep_array_indentation": false,
  "break_chained_methods": false,
  "indent_scripts": "normal",
  "brace_style": "collapse",
  "space_before_conditional": true,
  "unescape_strings": false,
  "jslint_happy": false,
  "end_with_newline": false,
  "wrap_line_length": "40",
  "indent_inner_html": false,
  "comma_first": false,
  "e4x": false,
  "indent_empty_lines": false
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:20
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
bitwisemancommented, Jul 17, 2020

@PeterShershov As I understand it, there are two problems here:

  1. (Breaking) the space between "top-bar top-bar" 100px is getting remove. This needs to be fixed asap.
  2. (Non-breaking) the multi-line formatting inside grid-template: is being changed to one line. This format will still work, but is not desirable. The should be fixed as well, but possibly later.

As a short term work around, perhaps we could disable newline reformatting inside grid-template:… but that might be just as hard as fixing.

1reaction
mhnaeemcommented, Apr 7, 2022

Added PR for this issue 🙃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grid layout using named grid lines - CSS - MDN Web Docs
Line naming is incredibly useful, but some of the more baffling looking grid syntax comes from this combination of names and track sizes....
Read more >
Understanding CSS Grid: Grid Template Areas
In a new series, Rachel Andrew breaks down the CSS Grid Layout ... An area is caused to span multiple tracks by repeating...
Read more >
A Complete Guide to CSS Grid
<track-size> – can be a length, a percentage, or a fraction of the ... Defines a grid template by referencing the names of...
Read more >
Grid Cheatsheet
Any rows/columns defined by grid-template-areas but not sized by ... a space-separated track list , the line names and track sizing functions of...
Read more >
How to Create a Perfect CSS Grid on Your Website [Sample ...
The CSS grid layout (also referred to as "the grid") was proposed to the ... and grid-template-rows property with lines names and values....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found