Merge pull request #6984 from KumJungMin/fix/issue-6572

fix(DataTable/BodyCell): apply updated cell value after value sorting
pull/7014/head
Tuğçe Küçükoğlu 2024-12-26 10:23:25 +03:00 committed by GitHub
commit d737502169
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 12 deletions

View File

@ -221,6 +221,7 @@ export default {
documentEditListener: null, documentEditListener: null,
selfClick: false, selfClick: false,
overlayEventListener: null, overlayEventListener: null,
editCompleteTimeout: null,
data() { data() {
return { return {
d_editing: this.editing, d_editing: this.editing,
@ -304,21 +305,32 @@ export default {
bindDocumentEditListener() { bindDocumentEditListener() {
if (!this.documentEditListener) { if (!this.documentEditListener) {
this.documentEditListener = (event) => { this.documentEditListener = (event) => {
if (!this.selfClick) { this.selfClick = this.$el && this.$el.contains(event.target);
this.completeEdit(event, 'outside');
if (this.editCompleteTimeout) {
clearTimeout(this.editCompleteTimeout);
} }
this.selfClick = false; if (!this.selfClick) {
this.editCompleteTimeout = setTimeout(() => {
this.completeEdit(event, 'outside');
}, 1);
}
}; };
document.addEventListener('click', this.documentEditListener); document.addEventListener('mousedown', this.documentEditListener);
} }
}, },
unbindDocumentEditListener() { unbindDocumentEditListener() {
if (this.documentEditListener) { if (this.documentEditListener) {
document.removeEventListener('click', this.documentEditListener); document.removeEventListener('mousedown', this.documentEditListener);
this.documentEditListener = null; this.documentEditListener = null;
this.selfClick = false; this.selfClick = false;
if (this.editCompleteTimeout) {
clearTimeout(this.editCompleteTimeout);
this.editCompleteTimeout = null;
}
} }
}, },
switchCellToViewMode() { switchCellToViewMode() {
@ -329,17 +341,13 @@ export default {
}, },
onClick(event) { onClick(event) {
if (this.editMode === 'cell' && this.isEditable()) { if (this.editMode === 'cell' && this.isEditable()) {
this.selfClick = true;
if (!this.d_editing) { if (!this.d_editing) {
this.d_editing = true; this.d_editing = true;
this.bindDocumentEditListener(); this.bindDocumentEditListener();
this.$emit('cell-edit-init', { originalEvent: event, data: this.rowData, field: this.field, index: this.rowIndex }); this.$emit('cell-edit-init', { originalEvent: event, data: this.rowData, field: this.field, index: this.rowIndex });
this.overlayEventListener = (e) => { this.overlayEventListener = (e) => {
if (this.$el && this.$el.contains(e.target)) { this.selfClick = this.$el && this.$el.contains(e.target);
this.selfClick = true;
}
}; };
OverlayEventBus.on('overlay-click', this.overlayEventListener); OverlayEventBus.on('overlay-click', this.overlayEventListener);
@ -393,20 +401,22 @@ export default {
} }
} }
}, },
moveToPreviousCell(event) { async moveToPreviousCell(event) {
let currentCell = this.findCell(event.target); let currentCell = this.findCell(event.target);
let targetCell = this.findPreviousEditableColumn(currentCell); let targetCell = this.findPreviousEditableColumn(currentCell);
if (targetCell) { if (targetCell) {
await this.$nextTick();
invokeElementMethod(targetCell, 'click'); invokeElementMethod(targetCell, 'click');
event.preventDefault(); event.preventDefault();
} }
}, },
moveToNextCell(event) { async moveToNextCell(event) {
let currentCell = this.findCell(event.target); let currentCell = this.findCell(event.target);
let targetCell = this.findNextEditableColumn(currentCell); let targetCell = this.findNextEditableColumn(currentCell);
if (targetCell) { if (targetCell) {
await this.$nextTick();
invokeElementMethod(targetCell, 'click'); invokeElementMethod(targetCell, 'click');
event.preventDefault(); event.preventDefault();
} }