Skip to content

Commit

Permalink
Fixed #1632 - Improve accessibility on Editable DataTable
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Oct 4, 2021
1 parent 1c142f8 commit 81ef7ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/datatable/BodyCell.vue
Expand Up @@ -113,6 +113,11 @@ export default {
if (this.columnProp('frozen')) {
this.updateStickyPosition();
}
if (this.d_editing && (this.editMode === 'cell' || (this.editMode === 'row' && this.columnProp('rowEditor')))) {
const focusableEl = DomHandler.getFirstFocusableElement(this.$el);
focusableEl && focusableEl.focus();
}
},
beforeUnmount() {
if (this.overlayEventListener) {
Expand Down
5 changes: 5 additions & 0 deletions src/components/utils/DomHandler.js
Expand Up @@ -470,6 +470,11 @@ export default {
return visibleFocusableElements;
},

getFirstFocusableElement(element) {
const focusableElements = this.getFocusableElements(element);
return focusableElements.length > 0 ? focusableElements[0] : null;
},

isClickable(element) {
const targetNode = element.nodeName;
const parentNode = element.parentElement && element.parentElement.nodeName;
Expand Down
1 change: 1 addition & 0 deletions src/components/utils/Utils.d.ts
Expand Up @@ -43,6 +43,7 @@ export declare class DomHandler {
static isVisible(el: HTMLElement): boolean;
static invokeElementMethod(el: HTMLElement, methodName: string, args: any): void;
static getFocusableElements(el: HTMLElement): any[];
static getFirstFocusableElement(el: HTMLElement): any;
static isClickable(el: HTMLElement): boolean;
static applyStyle(el: HTMLElement, style: any): void;
static isIOS(): boolean;
Expand Down

0 comments on commit 81ef7ee

Please sign in to comment.