Skip to content

Commit 93ba1e3

Browse files
committed
refactor: remove unnecessary header-hidden and footer-hidden attributes
Empty flex containers with no padding or min-height naturally collapse to zero height, making the visibility management logic unnecessary.
1 parent fd24435 commit 93ba1e3

File tree

3 files changed

+6
-37
lines changed

3 files changed

+6
-37
lines changed

packages/grid/src/styles/vaadin-grid-base-styles.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ export const gridStyles = css`
8080
box-sizing: border-box;
8181
}
8282
83-
:host([header-hidden]) [part='header'],
84-
:host([footer-hidden]) [part='footer'] {
85-
display: none;
86-
}
87-
8883
#items {
8984
flex-grow: 1;
9085
flex-shrink: 0;

packages/grid/src/vaadin-grid.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -278,32 +278,6 @@ class Grid extends GridMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjecti
278278
return gridStyles;
279279
}
280280

281-
/** @protected */
282-
firstUpdated() {
283-
super.firstUpdated();
284-
285-
// Handle header slot visibility
286-
const headerSlot = this.shadowRoot.querySelector('slot[name="header"]');
287-
const footerSlot = this.shadowRoot.querySelector('slot[name="footer"]');
288-
289-
const updateSlotVisibility = () => {
290-
// Check header slot
291-
const hasHeaderContent = headerSlot.assignedNodes().length > 0;
292-
this.toggleAttribute('header-hidden', !hasHeaderContent);
293-
294-
// Check footer slot
295-
const hasFooterContent = footerSlot.assignedNodes().length > 0;
296-
this.toggleAttribute('footer-hidden', !hasFooterContent);
297-
};
298-
299-
// Initial check
300-
updateSlotVisibility();
301-
302-
// Listen for slot changes
303-
headerSlot.addEventListener('slotchange', updateSlotVisibility);
304-
footerSlot.addEventListener('slotchange', updateSlotVisibility);
305-
}
306-
307281
/** @protected */
308282
render() {
309283
return html`

packages/grid/test/grid-slots.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ describe('grid slots', () => {
5252
expect(headerRect.bottom).to.be.at.most(tableRect.top + 1);
5353
});
5454

55-
it('should hide empty header slot', () => {
55+
it('should have zero height when header slot is empty', () => {
5656
const headerPart = grid.shadowRoot.querySelector('[part="header"]');
57-
const computedStyle = window.getComputedStyle(headerPart);
58-
expect(computedStyle.display).to.equal('none');
57+
const rect = headerPart.getBoundingClientRect();
58+
expect(rect.height).to.equal(0);
5959
});
6060

6161
it('should show header slot with content', async () => {
@@ -127,10 +127,10 @@ describe('grid slots', () => {
127127
expect(footerRect.top).to.be.at.least(tableRect.bottom - 1);
128128
});
129129

130-
it('should hide empty footer slot', () => {
130+
it('should have zero height when footer slot is empty', () => {
131131
const footerPart = grid.shadowRoot.querySelector('[part="footer"]');
132-
const computedStyle = window.getComputedStyle(footerPart);
133-
expect(computedStyle.display).to.equal('none');
132+
const rect = footerPart.getBoundingClientRect();
133+
expect(rect.height).to.equal(0);
134134
});
135135

136136
it('should show footer slot with content', async () => {

0 commit comments

Comments
 (0)