Skip to content

Commit

Permalink
fix: do not override custom header footer part names (#6632)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki authored Oct 11, 2023
1 parent 8f31475 commit af30824
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/grid/src/vaadin-grid-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ export const GridMixin = (superClass) =>
column._emptyCells.push(cell);
}
}
cell.setAttribute('part', `cell ${section}-cell`);
cell.part.add('cell', `${section}-cell`);
}

if (!cell._content.parentElement) {
Expand Down
8 changes: 4 additions & 4 deletions packages/grid/test/dom/__snapshots__/grid.test.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ snapshots["vaadin-grid shadow hidden column"] =
first-column=""
id="vaadin-grid-cell-1"
last-column=""
part="cell header-cell first-column-cell last-column-cell first-header-row-cell last-header-row-cell"
part="cell header-cell last-column-cell first-header-row-cell last-header-row-cell first-column-cell"
role="columnheader"
style="width: 100px; flex-grow: 1; order: 20000000;"
tabindex="0"
Expand Down Expand Up @@ -799,7 +799,7 @@ snapshots["vaadin-grid shadow hidden column"] =
first-column=""
id="vaadin-grid-cell-3"
last-column=""
part="cell footer-cell first-column-cell last-column-cell first-footer-row-cell last-footer-row-cell"
part="cell footer-cell last-column-cell first-footer-row-cell last-footer-row-cell first-column-cell"
role="gridcell"
style="width: 100px; flex-grow: 1; order: 20000000;"
tabindex="-1"
Expand Down Expand Up @@ -873,7 +873,7 @@ snapshots["vaadin-grid shadow hidden column selected"] =
first-column=""
id="vaadin-grid-cell-1"
last-column=""
part="cell header-cell first-column-cell last-column-cell first-header-row-cell last-header-row-cell"
part="cell header-cell last-column-cell first-header-row-cell last-header-row-cell first-column-cell"
role="columnheader"
style="width: 100px; flex-grow: 1; order: 20000000;"
tabindex="0"
Expand Down Expand Up @@ -958,7 +958,7 @@ snapshots["vaadin-grid shadow hidden column selected"] =
first-column=""
id="vaadin-grid-cell-3"
last-column=""
part="cell footer-cell first-column-cell last-column-cell first-footer-row-cell last-footer-row-cell"
part="cell footer-cell last-column-cell first-footer-row-cell last-footer-row-cell first-column-cell"
role="gridcell"
style="width: 100px; flex-grow: 1; order: 20000000;"
tabindex="-1"
Expand Down
16 changes: 16 additions & 0 deletions packages/grid/test/styling.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,21 @@ describe('styling', () => {
expect(headerCell.getAttribute('part')).to.not.contain('foobar');
expect(footerCell.getAttribute('part')).to.not.contain('bazqux');
});

it('should not override custom part names', () => {
const newColumn = document.createElement('vaadin-grid-column');
newColumn.path = 'value';
newColumn.headerPartName = 'foobar';
newColumn.footerPartName = 'bazqux';
grid.appendChild(newColumn);

flushGrid(grid);

const newHeaderCell = getContainerCell(grid.$.header, 0, 2);
const newFooterCell = getContainerCell(grid.$.footer, 0, 2);

expect(newHeaderCell.getAttribute('part')).to.contain('foobar');
expect(newFooterCell.getAttribute('part')).to.contain('bazqux');
});
});
});

0 comments on commit af30824

Please sign in to comment.