Skip to content

Commit

Permalink
prevent validation being skipped if creating new row on tab
Browse files Browse the repository at this point in the history
  • Loading branch information
olifolkerd committed Jan 21, 2024
1 parent 3204df2 commit 6c5a193
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
11 changes: 9 additions & 2 deletions dist/js/tabulator_esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7661,7 +7661,7 @@ class Edit$1 extends Module{
this.subscribe("column-delete", this.columnDeleteCheck.bind(this));
this.subscribe("row-deleting", this.rowDeleteCheck.bind(this));
this.subscribe("row-layout", this.rowEditableCheck.bind(this));
this.subscribe("data-refreshing", this.cancelEdit.bind(this));
this.subscribe("data-refreshing", this.dataRefresh.bind(this));

this.subscribe("keybinding-nav-prev", this.navigatePrev.bind(this, undefined));
this.subscribe("keybinding-nav-next", this.keybindingNavigateNext.bind(this));
Expand Down Expand Up @@ -7694,7 +7694,7 @@ class Edit$1 extends Module{
newRow = this.table.addRow(Object.assign({}, newRow));
}
}

newRow.then(() => {
setTimeout(() => {
cell.getComponent().navigateNext();
Expand Down Expand Up @@ -8033,6 +8033,12 @@ class Edit$1 extends Module{
cell.table.element.classList.remove("tabulator-editing");
}
}

dataRefresh(){
if(!this.invalidEdit){
this.cancelEdit();
}
}

cancelEdit(){
if(this.currentCell){
Expand Down Expand Up @@ -8203,6 +8209,7 @@ class Edit$1 extends Module{

return valid === true;
}else {
console.log("fail");
self.invalidEdit = true;
self.focusCellNoEvent(cell, true);
rendered();
Expand Down
2 changes: 1 addition & 1 deletion dist/js/tabulator_esm.js.map

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/js/modules/Edit/Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Edit extends Module{
this.subscribe("column-delete", this.columnDeleteCheck.bind(this));
this.subscribe("row-deleting", this.rowDeleteCheck.bind(this));
this.subscribe("row-layout", this.rowEditableCheck.bind(this));
this.subscribe("data-refreshing", this.cancelEdit.bind(this));
this.subscribe("data-refreshing", this.dataRefresh.bind(this));

this.subscribe("keybinding-nav-prev", this.navigatePrev.bind(this, undefined));
this.subscribe("keybinding-nav-next", this.keybindingNavigateNext.bind(this));
Expand Down Expand Up @@ -87,7 +87,7 @@ class Edit extends Module{
newRow = this.table.addRow(Object.assign({}, newRow));
}
}

newRow.then(() => {
setTimeout(() => {
cell.getComponent().navigateNext();
Expand Down Expand Up @@ -426,6 +426,12 @@ class Edit extends Module{
cell.table.element.classList.remove("tabulator-editing");
}
}

dataRefresh(){
if(!this.invalidEdit){
this.cancelEdit();
}
}

cancelEdit(){
if(this.currentCell){
Expand Down Expand Up @@ -596,6 +602,7 @@ class Edit extends Module{

return valid === true;
}else{
console.log("fail")
self.invalidEdit = true;
self.focusCellNoEvent(cell, true);
rendered();
Expand Down

0 comments on commit 6c5a193

Please sign in to comment.