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

Auto-width does not work with vaadin-grid-selection-column #7112

Closed
taow80 opened this issue Jan 30, 2024 · 4 comments
Closed

Auto-width does not work with vaadin-grid-selection-column #7112

taow80 opened this issue Jan 30, 2024 · 4 comments
Labels
waiting for author Further information is requested

Comments

@taow80
Copy link

taow80 commented Jan 30, 2024

Description

The width of the vaadin-grid-selection-column is not taken into account when calculating the width for the vaadin-grid-column using auto-width.

I believe this issue may be related to this bug, however, I installed 24.4.0-alpha2 to see if this fix would work for this issue, and it does not fix it.

Expected outcome

The width of the vaadin-grid-column with auto-width should be 100% of the grid with minus the width of the vaadin-grid-selection-column.

Minimal reproducible example

<script type="module">
  import '@vaadin/grid';
  import '@vaadin/grid/vaadin-grid-selection-column';

  const grid = document.querySelector('vaadin-grid');
  grid.items = [{ content: 'This is a long piece of content that should all display on the screen' }];
</script>

<vaadin-grid>
  <vaadin-grid-selection-column></vaadin-grid-selection-column>
  <vaadin-grid-column path="content" auto-width></vaadin-grid-column>
</vaadin-grid>

Steps to reproduce

Open an HTML page with the snippet above.
This is the result (the regular column has the 100% width of the page and is cutoff because it does not take into account the width of the grid selection column):

Screenshot 2024-01-30 at 1 05 04 PM

Here you can see that the viewport is 412px and the vaadin-grid-column is 413px, no matter the size of the viewport on reload it is always within a pixel of the width of the whole viewport. When it should be the width of the viewport minus the width of the selection column.

Screenshot 2024-01-30 at 1 05 12 PM

Environment

Vaadin version(s): 24.4.0-alpha2

Browsers

Issue is not browser related

@tomivirkki
Copy link
Member

Hi @taow80 , I tested the snipped you provided on 24.4.0-alpha2 and it works as expected: the column using auto-width gets a fixed width that equals the width of the widest cell content on the column:

Kapture.2024-01-31.at.16.22.44.mp4

If you want the column to have the width "100% of the grid with minus the width of the vaadin-grid-selection-column" then you can just leave out the auto-width:

<vaadin-grid>
  <vaadin-grid-selection-column></vaadin-grid-selection-column>
  <vaadin-grid-column path="content"></vaadin-grid-column>
</vaadin-grid>
Kapture.2024-01-31.at.16.26.12.mp4

@tomivirkki tomivirkki added the waiting for author Further information is requested label Jan 31, 2024
@tomivirkki
Copy link
Member

If you want the cell content to wrap as in your images, you can use the "wrap-cell-content" theme variant:

<vaadin-grid theme="wrap-cell-content">

@taow80
Copy link
Author

taow80 commented Jan 31, 2024

@tomivirkki Thank you! I tested just removing auto-width altogether and you're right! Sorry to bother you. I appreciate your help.

@tomivirkki
Copy link
Member

No problem, I'm glad it works. Closing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for author Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants