diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 3427220952..dff774462f 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -2749,7 +2749,7 @@ }, { "type": "number", - "label": "Width", + "label": "Initial width", "key": "width", "placeholder": "Auto" } diff --git a/packages/client/src/components/app/GridBlock.svelte b/packages/client/src/components/app/GridBlock.svelte index 27bb351f1a..5b3969de4f 100644 --- a/packages/client/src/components/app/GridBlock.svelte +++ b/packages/client/src/components/app/GridBlock.svelte @@ -36,13 +36,14 @@ } = getContext("sdk") let grid + let resizedColumns = {} $: columnWhitelist = parsedColumns ?.filter(col => col.active) ?.map(col => col.field) - $: schemaOverrides = getSchemaOverrides(parsedColumns) $: enrichedButtons = enrichButtons(buttons) $: parsedColumns = getParsedColumns(columns) + $: schemaOverrides = getSchemaOverrides(parsedColumns, resizedColumns) $: actions = [ { type: ActionTypes.RefreshDatasource, @@ -72,7 +73,6 @@ if (columns?.length && columns[0]?.active !== undefined) { return columns } - return columns?.map(column => ({ label: column.displayName || column.name, field: column.name, @@ -80,12 +80,17 @@ })) } - const getSchemaOverrides = columns => { + const getSchemaOverrides = (columns, resizedColumns) => { let overrides = {} columns?.forEach(column => { overrides[column.field] = { displayName: column.label, - width: column.width, + } + + // Only use the specified width until we resize the column, at which point + // we no longer want to override it + if (!resizedColumns[column.field]) { + overrides[column.field].width = column.width } }) return overrides @@ -119,6 +124,13 @@ }, } } + + const onColumnResize = e => { + // Mark that we've resized this column so we can remove this width from + // schema overrides if present + const { column } = e.detail + resizedColumns = { ...resizedColumns, [column]: true } + }