vaadin / vaadin/web-components

allRowsVisible makes grid claim more space in a row flex container

Open Beginner friendly
#12,486 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Impact: High requires new major Severity: Minor v26 vaadin-grid
Dominant language
JavaScript
Stars
582
Forks
102
Avg merge
13h 31m
Merged PRs (30d)
278

Description

Description

Setting allRowsVisible on a vaadin-grid that is a flex item in a row flex container makes it claim the container's full width, squeezing its siblings to nothing.

grid1.allRowsVisible = false grid1.allRowsVisible = true
Image Image
Both grids 414px wide Grid 1 = 836px, grid 2 = 2px

The cause is width: 100% in the :host([all-rows-visible]) rule in:

  • packages/grid/src/styles/vaadin-grid-base-styles.js
  • packages/vaadin-lumo-styles/src/components/grid.css

For base styles the declaration was explicitly added in https://github.com/vaadin/web-components/pull/10687, to fix an all-rows-visible grid not stretching in a vertical layout.

Expected outcome

allRowsVisible should only affect the grid's height.

Minimal reproducible example

<style>
  #layout {
    display: flex;
    flex-direction: row;
    width: 100%;
    gap: 8px;
  }
  #layout > vaadin-grid {
    flex-grow: 1;
  }
</style>

<div id="layout">
  <vaadin-grid id="grid-1">
    <vaadin-grid-column path="name" header="Grid 1"></vaadin-grid-column>
  </vaadin-grid>
  <vaadin-grid id="grid-2">
    <vaadin-grid-column path="name" header="Grid 2"></vaadin-grid-column>
  </vaadin-grid>
</div>
<button id="toggle">Toggle all rows visible</button>

<script type="module">
  import '@vaadin/grid/all-imports';

  const grid1 = document.querySelector('#grid-1');
  const grid2 = document.querySelector('#grid-2');

  grid1.items = [{ name: 'foo' }, { name: 'bar' }];
  grid2.items = [{ name: 'baz' }, { name: 'qux' }];

  document.querySelector('#toggle').addEventListener('click', () => {
    grid1.allRowsVisible = !grid1.allRowsVisible;
  });
</script>

Steps to reproduce

  1. Add the snippet above to an HTML page and open it in a 900px wide window.
  2. Note that both grids are 414px wide.
  3. Click "Toggle all rows visible".
  4. Note that grid 1 is now 836px wide and grid 2 has collapsed to 2px.

Environment

Vaadin version(s): 25.3.0-alpha13, also reproduces in 24.9
OS: macOS

Browsers

Issue is not browser related

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the :host([all-rows-visible]) rule in packages/grid/src/styles/vaadin-grid-base-styles.js and packages/vaadin-lumo-styles/src/components/grid.css. Reproduce the issue using the provided two-grid row flex layout, then verify that toggling allRowsVisible changes height without collapsing the sibling grid or changing the expected widths.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.