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

Add a resizeObserver to table cells to set cell height #862

Merged

Conversation

brentswisher
Copy link
Contributor

This change: (check at least one)

  • Adds a new feature
  • Fixes a bug
  • Improves maintainability
  • Improves documentation
  • Is a release activity

Is this a breaking change? (check one)

  • Yes
  • No

Is the: (complete all)

What does this change address?
It was impossible to set table cell content to fill the height of a cell. This allow that to happen.

How does this change work?
When using slotted content in a table cell, it currently is not possible to set the content to be 100% of the cell. This is because using a slot takes the content our of the normal flow and it doesn't know what height it should use when set to 100%. By adding a resizeObserver to see the height of the cell and set that height manually, the descendant content can set height:100% and it will work as expected.

While each cell will be set to it's own height, the nature of table rows means that all cells in a row will display as the height of the tallest cell, regardless of what height they have manually set.

Additional context
This is stacked on top of #840 for easier reviewing and will be merged into it before merging both change to develop at once

When using slotted content in a table cell, it currently
is not possible to set the content to be 100% of the cell.
This is because using a slot takes the content our of the normal
flow and it doesn't know what height it should use when
set to 100%. By adding a resizeObserver to see the height of the cell
and set that height manually, the descendant content can set
height:100% and it will work as expected.

While each cell will be set to it's own height, the nature of
table rows means that all cells in a row will display as the
height of the tallest cell, regardless of what height they have
manually set.
@brentswisher brentswisher self-assigned this Jan 29, 2025
@brentswisher brentswisher requested a review from a team as a code owner January 29, 2025 22:03
@brentswisher brentswisher requested review from sirrah-tam, mtorres3 and satya-achanta-venkata and removed request for a team January 29, 2025 22:03
Copy link

changeset-bot bot commented Jan 29, 2025

⚠️ No Changeset found

Latest commit: 7c0b71f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Member

@daneah daneah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this makes sense to disconnect after the work is done! Nice going.

@brentswisher
Copy link
Contributor Author

🤔 Something it making it grow very slightly for each row - https://www.chromatic.com/test?appId=60919c26122bd50039b34644&id=679aa5fdfaecae4253b8e997

@brentswisher
Copy link
Contributor Author

Something it making it grow very slightly for each row
Updates, just needed to account for the border height too

@brentswisher brentswisher merged commit 6e9c553 into feature/complex-table-data Jan 30, 2025
6 checks passed
@brentswisher brentswisher deleted the fix/manually-set-table-cell-height branch January 30, 2025 14:09
brentswisher added a commit that referenced this pull request Jan 30, 2025
* feat(table): allow more complex data in table

* chore(table): add changeset

* feat(table): update table rowData tests

* feat(table): add tests for content added via slot

* feat(table): add test coverage for new elements

* fix: revert unintended update to changelog

* Add a resizeObserver to table cells to set cell height (#862)

* fix(table): add resizeObserver to set cell height

When using slotted content in a table cell, it currently
is not possible to set the content to be 100% of the cell.
This is because using a slot takes the content our of the normal
flow and it doesn't know what height it should use when
set to 100%. By adding a resizeObserver to see the height of the cell
and set that height manually, the descendant content can set
height:100% and it will work as expected.

While each cell will be set to it's own height, the nature of
table rows means that all cells in a row will display as the
height of the tallest cell, regardless of what height they have
manually set.

* fix(table): account for border when calculating height
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants