Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PeterShershov opened this issue Jul 16, 2020 · 5 comments · Fixed by #2018
Closed

Comments

@PeterShershov
Copy link

PeterShershov commented Jul 16, 2020

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
}
@PeterShershov PeterShershov changed the title CSS Grid template formatting is broken when adding track size after line names. CSS Grid template formatting is broken when adding track size after line names Jul 16, 2020
@bitwiseman bitwiseman added this to the v1.11.x milestone Jul 17, 2020
@bitwiseman
Copy link
Member

@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.

@bitwiseman bitwiseman modified the milestones: v1.11.x, v1.12.x Aug 13, 2020
@bitwiseman bitwiseman modified the milestones: v1.12.x, 1.13.x Aug 20, 2020
@bitwiseman bitwiseman modified the milestones: v1.13.1, v1.13.x Jan 8, 2021
@bitwiseman bitwiseman modified the milestones: v1.13.6, v1.13.x Jan 26, 2021
@bitwiseman bitwiseman modified the milestones: v1.13.7, v1.13.x Apr 13, 2021
@VladyslavG
Copy link

vote for the issue and subscribe to updates

@bitwiseman bitwiseman modified the milestones: v1.14.1, v1.14.x, v1.15.x Mar 28, 2022
@zakharenkov
Copy link

Same problem

@bitwiseman
Copy link
Member

@zakharenkov @VladyslavG
PRs welcome.

mhnaeem added a commit to mhnaeem/js-beautify that referenced this issue Apr 7, 2022
…rts and if followed by a string lose formatting. Also add multiline support for grid-template property
@mhnaeem
Copy link
Contributor

mhnaeem commented Apr 7, 2022

Added PR for this issue 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants