Skip to content

Commit 81507bd

Browse files
committed
[ML] Add sticky header for field stats table in Discover
1 parent 3dc8912 commit 81507bd

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

x-pack/plugins/data_visualizer/public/application/common/components/stats_table/_index.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ $panelWidthL: #{'max(40%, 450px)'};
3131
}
3232

3333
.euiTableRow > .euiTableRowCell {
34-
border-bottom: 0;
35-
border-top: $euiBorderThin;
36-
34+
border-top: 0;
35+
border-bottom: $euiBorderThin;
3736
}
3837

3938
.euiTableCellContent {

x-pack/plugins/data_visualizer/public/application/common/components/stats_table/data_visualizer_stats_table.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ import {
2020
RIGHT_ALIGNMENT,
2121
EuiResizeObserver,
2222
EuiLoadingSpinner,
23+
useEuiTheme,
2324
} from '@elastic/eui';
2425
import { i18n } from '@kbn/i18n';
2526
import { EuiTableComputedColumnType } from '@elastic/eui/src/components/basic_table/table_types';
2627
import { throttle } from 'lodash';
28+
import { css } from '@emotion/react';
2729
import { JOB_FIELD_TYPES } from '../../../../../common/constants';
2830
import type { JobFieldType, DataVisualizerTableState } from '../../../../../common/types';
2931
import { DocumentStat } from './components/field_data_row/document_stats';
@@ -70,6 +72,8 @@ export const DataVisualizerTable = <T extends DataVisualizerTableItem>({
7072
onChange,
7173
loading,
7274
}: DataVisualizerTableProps<T>) => {
75+
const { euiTheme } = useEuiTheme();
76+
7377
const [expandedRowItemIds, setExpandedRowItemIds] = useState<string[]>([]);
7478
const [expandAll, setExpandAll] = useState<boolean>(false);
7579

@@ -361,6 +365,18 @@ export const DataVisualizerTable = <T extends DataVisualizerTableItem>({
361365
rowProps={(item) => ({
362366
'data-test-subj': `dataVisualizerRow row-${item.fieldName}`,
363367
})}
368+
css={css`
369+
thead {
370+
position: sticky;
371+
inset-block-start: 0;
372+
z-index: 1;
373+
background-color: ${euiTheme.colors.emptyShade};
374+
box-shadow: inset 0 0px 0, inset 0 -1px 0 ${euiTheme.border.color};
375+
}
376+
.euiTableRow > .euiTableRowCel {
377+
border-top: 0px;
378+
}
379+
`}
364380
/>
365381
</div>
366382
)}

0 commit comments

Comments
 (0)