Skip to content

Commit

Permalink
Change queryselector to target outer table's header (#2661)
Browse files Browse the repository at this point in the history
* chore: change queryselector to target parent level table header

* chore: add changeset

* chore: update changeset desc
  • Loading branch information
jaikumar-tj authored Dec 4, 2023
1 parent 88ae460 commit 237f5bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/fuzzy-dogs-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-uikit/data-table': patch
---

Updated table columns width calculation to take into account only main table header. This allows for having nested tables in its rows.

Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ const useManualColumnResizing = (tableRef?: TTableRef) => {
// if the table element has been rendered and we haven't yet measured the columns
if (state.tableRef?.current && !state.sizes) {
const renderedColumnMeasurements: TRenderedColumnMeasurements[] = [];
state.tableRef.current.querySelectorAll('th').forEach((header) => {
renderedColumnMeasurements.push({
key: header.getAttribute('data-id'),
width: header.getBoundingClientRect().width,
state.tableRef.current
.querySelectorAll(':scope > thead > tr > th')
.forEach((header) => {
renderedColumnMeasurements.push({
key: header.getAttribute('data-id'),
width: header.getBoundingClientRect().width,
});
});
});

dispatch({
type: 'registerColumnMeasurements',
Expand Down

1 comment on commit 237f5bd

@vercel
Copy link

@vercel vercel bot commented on 237f5bd Dec 4, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.