Skip to content

Commit

Permalink
fix: fix error when deleting the content of a table cell with DEL key
Browse files Browse the repository at this point in the history
  • Loading branch information
csm-thu committed Jun 22, 2023
1 parent 230d367 commit 7a44db0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/inputs/Table/ColumnTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const _editModeSetter = (params) => {
};

const _boolSetter = (params) => {
let newValue = params.newValue.toLowerCase();
let newValue = params.newValue?.toLowerCase() ?? '';
const allowedEmptyField = params.colDef.cellEditorParams?.acceptsEmptyFields && newValue.length === 0;
if (!params.context.editMode) {
newValue = params.oldValue;
Expand All @@ -30,7 +30,7 @@ const _boolSetter = (params) => {

const _dateSetter = (params) => {
const dateFormat = params.context.dateFormat;
let newValue = params.newValue;
let newValue = params.newValue ?? '';
const allowedEmptyField =
params.context.editMode && params.colDef.cellEditorParams?.acceptsEmptyFields && newValue.length === 0;
if (allowedEmptyField) {
Expand All @@ -55,7 +55,7 @@ const _dateSetter = (params) => {
};

const _intSetter = (params) => {
let newValue = params.newValue;
let newValue = params.newValue ?? '';
const allowedEmptyField =
params.context.editMode && params.colDef.cellEditorParams?.acceptsEmptyFields && newValue.length === 0;
if (!allowedEmptyField) {
Expand All @@ -80,7 +80,7 @@ const _intSetter = (params) => {
};

const _numberSetter = (params) => {
let newValue = params.newValue;
let newValue = params.newValue ?? '';
const allowedEmptyField =
params.context.editMode && params.colDef.cellEditorParams?.acceptsEmptyFields && newValue.length === 0;
if (!allowedEmptyField) {
Expand Down Expand Up @@ -108,7 +108,7 @@ const _enumSetter = (params) => {
if (enumValues.length === 0) {
console.warn(`Missing enum values for table column "${params.column.colId}"`);
}
let newValue = params.newValue;
let newValue = params.newValue ?? '';
const allowedEmptyField = params.colDef.cellEditorParams?.acceptsEmptyFields && newValue.length === 0;
if (!allowedEmptyField && (!params.context.editMode || enumValues.indexOf(newValue) === -1)) {
newValue = params.oldValue;
Expand Down

0 comments on commit 7a44db0

Please sign in to comment.