fix: measure auto-width correctly for focusButtonMode columns #7046
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 originalwidth
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 withposition: 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 thediv
and then restore the positioning after the measurement. I believe that setting ameasuring-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
Checklist