Stringify non strings when pasting into text cells

This commit is contained in:
Andrew Kingston 2024-07-19 16:34:20 +01:00
parent 2473b82ba5
commit 2ecedcea7c
No known key found for this signature in database
1 changed files with 14 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import { getCellID, parseCellID } from "../lib/utils"
import { tick } from "svelte"
import { Helpers } from "@budibase/bbui"
import { sleep } from "../../../utils/utils"
import { FieldType } from "@budibase/types"
export const createStores = () => {
const rows = writable([])
@ -421,8 +422,21 @@ export const createActions = context => {
// valid pending change was made or not
const stashRowChanges = (rowId, changes) => {
const $rowLookupMap = get(rowLookupMap)
const $columnLookupMap = get(columnLookupMap)
const row = $rowLookupMap[rowId]
// Coerce some values into the correct types
for (let column of Object.keys(changes || {})) {
const type = $columnLookupMap[column]?.schema?.type
// Stringify objects
if (type === FieldType.STRING || type == FieldType.LONGFORM) {
if (changes[column] != null && typeof changes[column] !== "string") {
changes[column] = JSON.stringify(changes[column])
}
}
}
// Check this is a valid change
if (!row || !changesAreValid(row, changes)) {
return false