From 27c3be9d7e60e31578f7e5435c3cf95be9ae7920 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 25 Mar 2021 08:15:13 +0000 Subject: [PATCH] Fix table scrollbars affecting height calculation --- .../src/table/Table.svelte | 111 +++++++++--------- 1 file changed, 54 insertions(+), 57 deletions(-) diff --git a/packages/standard-components/src/table/Table.svelte b/packages/standard-components/src/table/Table.svelte index 02e3b4e968..51acf3c44d 100644 --- a/packages/standard-components/src/table/Table.svelte +++ b/packages/standard-components/src/table/Table.svelte @@ -16,24 +16,19 @@ let sortColumn let sortOrder - $: styles = makeStyles($component.styles, rowCount) $: rows = dataProvider?.rows ?? [] + $: contentStyle = getContentStyle(rowCount, rows.length) $: sortedRows = sortRows(rows, sortColumn, sortOrder) $: loaded = dataProvider?.loaded ?? false $: schema = dataProvider?.schema ?? {} $: fields = getFields(schema, columns, showAutoColumns) - const makeStyles = (styles, rowCount) => { + const getContentStyle = (rowCount, dataCount) => { if (!rowCount) { - return styles - } - return { - ...styles, - normal: { - ...styles.normal, - height: `${37 + rowCount * 56}px`, - }, + return "" } + const actualCount = Math.min(rowCount, dataCount) + return `height: ${36 + actualCount * 56}px;` } const sortRows = (rows, sortColumn, sortOrder) => { @@ -80,59 +75,61 @@
- - - - {#if $component.children} - - {/if} - {#each fields as field} - - {/each} - - - - {#each sortedRows as row} - + use:styleable={$component.styles} + class={`spectrum ${size || 'spectrum--medium'} ${theme || 'spectrum--light'}`}> +
+
-
-
sortBy(field)}> -
- {schema[field]?.name} - -
-
+ + {#if $component.children} - + {/if} {#each fields as field} - {/each} - {/each} - -
-
- - - -
-
+
+
-
- +
sortBy(field)}> +
+ {schema[field]?.name} +
- +
+ + + {#each sortedRows as row} + + {#if $component.children} + +
+ + + +
+ + {/if} + {#each fields as field} + +
+ +
+ + {/each} + + {/each} + + +