Skip to content

Commit

Permalink
Fixed #2561 - Calendar as editor inside DataTable in row edit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jan 19, 2022
1 parent 5a3aec3 commit 65f99f9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion components/lib/datatable/BodyCell.js
Expand Up @@ -196,14 +196,22 @@ export class BodyCell extends Component {
clearTimeout(this.tabindexTimeout);
this.tabindexTimeout = setTimeout(() => {
if (this.state.editing) {
const focusableEl = DomHandler.getFirstFocusableElement(this.el, ':not(.p-cell-editor-key-helper)');
const focusableEl = this.props.editMode === 'cell' ? DomHandler.getFirstFocusableElement(this.el, ':not(.p-cell-editor-key-helper)') : DomHandler.findSingle(this.el, '.p-row-editor-save');
focusableEl && focusableEl.focus();
}

this.keyHelper && (this.keyHelper.tabIndex = this.state.editing ? -1 : 0);
}, 1);
}

focusOnInit() {
clearTimeout(this.initFocusTimeout);
this.initFocusTimeout = setTimeout(() => {
const focusableEl = this.props.editMode === 'row' ? DomHandler.findSingle(this.el, '.p-row-editor-init') : null;
focusableEl && focusableEl.focus();
}, 1);
}

updateStickyPosition() {
if (this.getColumnProp('frozen')) {
let styleObject = { ...this.state.styleObject };
Expand Down Expand Up @@ -424,10 +432,12 @@ export class BodyCell extends Component {

onRowEditSave(event) {
this.props.onRowEditSave({ originalEvent: event, data: this.props.rowData, newData: this.getEditingRowData(), field: this.field, index: this.props.rowIndex });
this.focusOnInit();
}

onRowEditCancel(event) {
this.props.onRowEditCancel({ originalEvent: event, data: this.props.rowData, newData: this.getEditingRowData(), field: this.field, index: this.props.rowIndex });
this.focusOnInit();
}

bindDocumentEditListener() {
Expand Down

0 comments on commit 65f99f9

Please sign in to comment.