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

fix: measure auto-width correctly for focusButtonMode columns #7046

Conversation

bwajtr
Copy link
Contributor

@bwajtr bwajtr commented Dec 29, 2023

Description

When calculating the auto-width of the grid column, the cells of the column are temporarily set to have width: auto (in here). This helps to fully expand the cell content and therefore gives a chance to measure the real total width of the cell content. This number is then taken into account when calculating the auto-width. Once the calculation is done, the original width of the cell is restored.

For the vaadin-grid-pro-edit-column, this mechanism didn't work correctly, because this column wraps the cell's slot with an additional div (aka wrapping-div) because of accessibility reasons - using the focusButtonMode property. This wrapping element has style set to use the absolute positioning.

The problem is that when you set the cell to width: auto and have a wrapping-div in it with position: absolute, then the width of the wrapping-div collapses to zero (instead of the full width of the content)... and therefore the auto-width mechanism computation fails.

The solution here is to temporarily set the wrapping-div positioning to static, so we can measure the width of the div and then restore the positioning after the measurement. I believe that setting a measuring-auto-width attribute on the cell opens a way how to fix similar problems with cell width measuring also in the future.

Fixes #6985

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/contributing/overview
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.
  • I have not completed some of the steps above and my pull request can be closed immediately.

@bwajtr bwajtr requested review from web-padawan and vursen December 29, 2023 10:33
packages/grid/src/vaadin-grid-mixin.js Outdated Show resolved Hide resolved
Copy link

sonarqubecloud bot commented Jan 4, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@bwajtr bwajtr merged commit b152955 into main Jan 4, 2024
9 checks passed
@bwajtr bwajtr deleted the fix/6985-auto-width-does-not-work-with-vaadin-grid-pro-edit-column branch January 4, 2024 19:05
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.4.0.alpha1 and is also targeting the upcoming stable 24.4.0 version.

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

Successfully merging this pull request may close these issues.

Auto-width does not work with vaadin-grid-pro-edit-column
3 participants