diff --git a/packages/frontend-core/src/components/grid/cells/DataCell.svelte b/packages/frontend-core/src/components/grid/cells/DataCell.svelte index 179be0c90e..863a40a821 100644 --- a/packages/frontend-core/src/components/grid/cells/DataCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/DataCell.svelte @@ -6,6 +6,7 @@ const { rows, + columns, focusedCellId, focusedCellAPI, menu, @@ -40,13 +41,10 @@ // Determine if the cell is editable $: readonly = - column.schema.autocolumn || - column.schema.disabled || - column.schema.type === "formula" || - (!$config.canEditRows && !row._isNewRow) || - column.schema.readonly + columns.actions.isReadonly(column) || + (!$config.canEditRows && !row._isNewRow) - // Register this cell API if the row is focused + // Register this cell API if this cell is focused $: { if (focused) { focusedCellAPI.set(cellAPI) diff --git a/packages/frontend-core/src/components/grid/stores/columns.js b/packages/frontend-core/src/components/grid/stores/columns.js index e0c44db1df..8b040ba067 100644 --- a/packages/frontend-core/src/components/grid/stores/columns.js +++ b/packages/frontend-core/src/components/grid/stores/columns.js @@ -110,11 +110,24 @@ export const createActions = context => { await datasource.actions.saveSchemaMutations() } + const isReadonly = column => { + if (!column?.schema) { + return false + } + return ( + column.schema.autocolumn || + column.schema.disabled || + column.schema.type === "formula" || + column.schema.readonly + ) + } + return { columns: { ...columns, actions: { changeAllColumnWidths, + isReadonly, }, }, }