Skip to content

Commit 9e162d6

Browse files
annawen1Gururajj77
andauthored
feat(data-table): parity - make data-table header sticky (#20780)
* feat(data-table): make data-table header sticky * fix: add overflow to batch-actions --------- Co-authored-by: Gururaj J <89023023+Gururajj77@users.noreply.github.com>
1 parent 24fb8b0 commit 9e162d6

File tree

3 files changed

+18
-25
lines changed

3 files changed

+18
-25
lines changed

packages/web-components/src/components/data-table/_table-action.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
@extend .#{$prefix}--batch-actions;
150150

151151
box-sizing: border-box;
152+
overflow-x: auto;
152153
}
153154

154155
:host(#{$prefix}-table-batch-actions[active]) {

packages/web-components/src/components/data-table/_table-core.scss

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
:host(#{$prefix}-table) {
1313
@extend .#{$prefix}--data-table;
1414

15-
display: table;
16-
1715
::slotted(#{$prefix}-table-head) {
1816
@include type-style('heading-01');
1917

@@ -36,6 +34,11 @@
3634
inline-size: auto;
3735
}
3836

37+
.#{$prefix}--data-table-content {
38+
display: table;
39+
inline-size: 100%;
40+
}
41+
3942
:host(#{$prefix}-table[sticky-header]) {
4043
::slotted(#{$prefix}-table-head),
4144
::slotted(#{$prefix}-table-body) {
@@ -50,14 +53,12 @@
5053
}
5154
}
5255

53-
:host(#{$prefix}-table[with-header]) {
54-
.#{$prefix}--data-table-header-container {
55-
display: table-caption;
56-
}
57-
}
58-
.#{$prefix}--data-table-header-container {
59-
display: table-caption;
56+
.#{$prefix}--data-table_inner-container {
57+
display: block;
58+
inline-size: 100%;
59+
overflow-x: auto;
6060
}
61+
6162
:host(#{$prefix}-table-head[sticky-header]) {
6263
position: sticky;
6364
z-index: 1;

packages/web-components/src/components/data-table/table.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -893,10 +893,8 @@ class CDSTable extends HostListenerMixin(LitElement) {
893893
});
894894
}
895895

896-
/* eslint-disable no-constant-condition */
897896
render() {
898-
return html`
899-
<div class="${prefix}--data-table-header-container">
897+
return html` <div class="${prefix}--data-table-header-container">
900898
<div ?hidden="${!this.withHeader}" class="${prefix}--data-table-header">
901899
<slot @slotchange="${this._handleSlotChange}" name="title"></slot>
902900
<slot
@@ -906,18 +904,13 @@ class CDSTable extends HostListenerMixin(LitElement) {
906904
<slot name="toolbar"></slot>
907905
</div>
908906
909-
${false // TODO: replace with this.stickyHeader when feature is fully implemented
910-
? html` <div class="${prefix}--data-table_inner-container">
911-
<div class="${prefix}--data-table-content">
912-
<slot
913-
@cds-table-body-content-change="${this
914-
._handleTableBodyChange}"></slot>
915-
</div>
916-
</div>`
917-
: html`<slot
907+
<div class="${prefix}--data-table_inner-container">
908+
<div class="${prefix}--data-table-content">
909+
<slot
918910
@cds-table-body-content-change="${this
919-
._handleTableBodyChange}"></slot>`}
920-
`;
911+
._handleTableBodyChange}"></slot>
912+
</div>
913+
</div>`;
921914
}
922915

923916
/**
@@ -955,8 +948,6 @@ class CDSTable extends HostListenerMixin(LitElement) {
955948
this._handleSortAction(columnIndex, sortDirection);
956949
}
957950

958-
/* eslint-enable no-constant-condition */
959-
960951
/**
961952
* The name of the custom event fired before a new sort direction is set upon a user gesture.
962953
* Cancellation of this event stops the user-initiated change in sort direction.

0 commit comments

Comments
 (0)