Skip to content

A platform for community discussion. Free, open, simple.

UX: Keep workflow data table header and scrollbar in view (#44597)

Régis Hanol63f0a2c035bb
diff --git a/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/data-table/viewer.gjs b/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/data-table/viewer.gjs
index 9144f336157..5caa1792076 100644
--- a/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/data-table/viewer.gjs
+++ b/plugins/discourse-workflows/admin/assets/javascripts/admin/components/workflows/data-table/viewer.gjs
@@ -28,6 +28,12 @@ function syncInputWidth(input) {
input.style.setProperty("--col-name-length", input.value.length || 1);
}
+// Lets CSS size the scroll box to end at the bottom of the viewport.
+const measureTopOffset = modifier((element) => {
+ const top = element.getBoundingClientRect().top + window.scrollY;
+ element.style.setProperty("--top-offset", `${top}px`);
+});
+
const indeterminate = modifier((element, [value]) => {
element.indeterminate = value;
});
@@ -320,8 +326,8 @@ export default class DataTableViewer extends Component {
</div>
<DConditionalLoadingSpinner @condition={{this.isLoading}}>
- <DLoadMore @action={{this.loadMore}} @enabled={{this.canLoadMore}}>
- <div class="workflows-data-table-viewer__scroll">
+ <div class="workflows-data-table-viewer__scroll" {{measureTopOffset}}>
+ <DLoadMore @action={{this.loadMore}} @enabled={{this.canLoadMore}}>
<table class="workflows-data-table-viewer__table">
<thead>
<tr>
@@ -412,9 +418,9 @@ export default class DataTableViewer extends Component {
</tr>
</tbody>
</table>
- </div>
+ </DLoadMore>
<DConditionalLoadingSpinner @condition={{this.loadingMore}} />
- </DLoadMore>
+ </div>
</DConditionalLoadingSpinner>
</div>
</template>
diff --git a/plugins/discourse-workflows/assets/stylesheets/common/data-table/data-tables.scss b/plugins/discourse-workflows/assets/stylesheets/common/data-table/data-tables.scss
index cedff9f141f..fad86d215ba 100644
--- a/plugins/discourse-workflows/assets/stylesheets/common/data-table/data-tables.scss
+++ b/plugins/discourse-workflows/assets/stylesheets/common/data-table/data-tables.scss
@@ -62,8 +62,11 @@
gap: var(--space-2);
}
+ // Bounded height makes this the vertical scroller too, so the horizontal
+ // scrollbar stays on screen and the sticky header has something to stick to.
&__scroll {
- overflow-x: auto;
+ overflow: auto;
+ max-height: max(50dvh, calc(100dvh - var(--top-offset) - var(--space-4)));
}
&__table {
@@ -80,10 +83,16 @@
}
th {
+ position: sticky;
+ top: 0;
+ z-index: 1;
padding: var(--space-2) var(--space-3);
background: var(--primary-very-low);
font-weight: 700;
white-space: nowrap;
+
+ // collapsed borders belong to the table and scroll away from sticky cells
+ box-shadow: inset 0 -1px 0 var(--primary-low);
}
th.--id,