Skip to content

List View Formatting child element width in percentages is rendered differently when hideSelection=false than when hideSelection=true #9100

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

Open
3 of 9 tasks
waholayo opened this issue Jul 25, 2023 · 1 comment
Labels
area:list-formatting Category: View, row & column formatting with JSON type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Comments

@waholayo
Copy link

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

Declarative list formatting

Developer environment

None

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

Edge 115.0.1901.183 (Official build) (64-bit)
Chrome 115.0.5790.102 (Official Build) (64-bit)
Firefox 115.0.3esr (64-bit)

Describe the bug / error

In List View Formatting, when specifying the element widths div in percentages and setting hideSelection to false, the widths of the child div elements varies for each row; while setting hideSelection to true, the widths of the child div become the same for each row.
"hideSelection": false
"hideSelection": true

"hideSelection": false
"hideSelection": true
image

Specifying width in percentage makes this CSS table responsive to window resizing. The View Formatting JSON is derived from sample https://github.com/pnp/List-Formatting/tree/master/view-samples/custom-header.

Steps to reproduce

  1. Create a List and choose some columns to be shown;
  2. Create some items with non-empty values for the columns;
  3. Format View:
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "debug": true,
  "hideSelection": false,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "display": "flex",
      "flex-direction": "column",
      "align-items": "flex-start",
      "max-width": "1200px"
    },
    "children": [
      {
        "elmType": "div",
        "__comment": "thead",
        "attributes": {
          "class": "sp-css-backgroundColor-themeLight"
        },
        "style": {
          "display": "=if(@rowIndex == 0, 'flex', 'none')",
          "width": "=(1-(40/@window.innerWidth))*100+'%'",
          "padding": "0.2em 1em",
          "border-width": "0.5px",
          "border-color": "lightgray",
          "border-style": "dotted"
        },
        "children": [
          {
            "elmType": "div",
            "txtContent": "lookup 1",
            "style": {
              "flex-grow": "1",
              "align-items": "left",
              "width": "5%",
              "min-width": "2em",
              "padding": "0.2em 1em 0.2em 0em",
              "border-width": "0.5px",
              "border-color": "lightgray",
              "border-left-style": "dotted"
            }
          },
          {
            "elmType": "div",
            "txtContent": "Title",
            "style": {
              "flex-grow": "1",
              "align-items": "left",
              "width": "20%",
              "min-width": "12em",
              "padding": "0.2em 1em",
              "border-width": "0.5px",
              "border-color": "lightgray",
              "border-left-style": "dotted"
            }
          },
          {
            "elmType": "div",
            "txtContent": "calculated",
            "style": {
              "flex-grow": "1",
              "align-items": "left",
              "width": "35%",
              "min-width": "15em",
              "padding": "0.2em 1em",
              "border-width": "0.5px",
              "border-color": "lightgray",
              "border-left-style": "dotted"
            }
          },
          {
            "elmType": "div",
            "txtContent": "lookup 2",
            "style": {
              "flex-grow": "1",
              "align-items": "left",
              "width": "10%",
              "min-width": "7em",
              "padding": "0.2em 1em",
              "border-width": "0.5px",
              "border-color": "lightgray",
              "border-left-style": "dotted"
            }
          }
        ]
      },
      {
        "elmType": "div",
        "__comment": "tbody",
        "style": {
          "display": "flex",
          "width": "=(1-(40/@window.innerWidth))*100+'%'",
          "min-height": "3.5em",
          "padding": "0em 1em",
          "border-width": "0.5px",
          "border-color": "lightgray",
          "border-style": "dotted",
          "border-top-style": "none"
        },
        "children": [
          {
            "elmType": "div",
            "txtContent": "[$lookupColumn.lookupValue]",
            "style": {
              "flex-grow": "1",
              "align-items": "left",
              "text-wrap": "wrap",
              "white-space": "normal",
              "width": "5%",
              "min-width": "2em",
              "padding": "0.2em 1em 0.2em 0em",
              "border-width": "0.5px",
              "border-color": "lightgray",
              "border-left-style": "none"
            }
          },
          {
            "elmType": "div",
            "txtContent": "[$Title]",
            "style": {
              "flex-grow": "1",
              "align-items": "left",
              "text-wrap": "wrap",
              "white-space": "normal",
              "width": "20%",
              "min-width": "12em",
              "padding": "0.5em 1em",
              "border-width": "0.5px",
              "border-color": "lightgray",
              "border-left-style": "dotted"
            }
          },
          {
            "elmType": "div",
            "txtContent": "[$calculated]",
            "style": {
              "flex-grow": "1",
              "align-items": "left",
              "text-wrap": "wrap",
              "white-space": "normal",
              "width": "35%",
              "min-width": "12em",
              "padding": "0.5em 1em",
              "border-width": "0.5px",
              "border-color": "lightgray",
              "border-left-style": "dotted"
            }
          },
          {
            "elmType": "div",
            "txtContent": "[$lookupColumn2.lookupValue]",
            "style": {
              "flex-grow": "1",
              "align-items": "left",
              "text-wrap": "wrap",
              "white-space": "normal",
              "width": "10%",
              "min-width": "7em",
              "padding": "0.5em 1em",
              "border-width": "0.5px",
              "border-color": "lightgray",
              "border-left-style": "dotted"
            }
          }
        ]
      }
    ]
  }
}
  1. Toggle bewteen "hideSelection": false, and "hideSelection": true, and preview the difference.

Expected behavior

The widths of the elements should be the same for all rows when specified in percentages, no matter the value of hideSelection.

@waholayo waholayo added the type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. label Jul 25, 2023
@ghost
Copy link

ghost commented Jul 25, 2023

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 Awaiting categorization and initial review. label Jul 25, 2023
@waholayo waholayo changed the title View Formatting child element width in percentages is rendered differently when hideSelection=false than when hideSelection=true List View Formatting child element width in percentages is rendered differently when hideSelection=false than when hideSelection=true Jul 26, 2023
@VesaJuvonen VesaJuvonen added area:list-formatting Category: View, row & column formatting with JSON and removed Needs: Triage 🔍 Awaiting categorization and initial review. labels Aug 3, 2023
@VesaJuvonen VesaJuvonen added type:archive-old-issue Issues which are closed as tool old for active work and removed type:archive-old-issue Issues which are closed as tool old for active work labels May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:list-formatting Category: View, row & column formatting with JSON type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Projects
None yet
Development

No branches or pull requests

2 participants