Skip to content

Commit

Permalink
ELEMENTS-1697: update tabindex & lastindex in nuxeo-data-grid
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshkumar1019 committed Dec 12, 2023
1 parent 936f07c commit 8c6e8d1
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions ui/nuxeo-data-grid/nuxeo-data-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,42 @@ import { PageProviderDisplayBehavior } from '../nuxeo-page-provider-display-beha
type: Boolean,
value: false,
},

_lastIndex: {
type: Number,
value: 0,
},

_lastIndexValue: {
type: Number,
value: 0,
},
};
}

static get observers() {
return ['_fetchMissingItems(loading)'];
return ['_fetchMissingItems(loading)', '_lastIndexChanged(lastIndex)'];
}

ready() {
super.ready();
this.addEventListener('iron-resize', this._fetchMissingItems);
this.addEventListener('keydown', this._handleKeyDown);
}

_handleKeyDown(event) {
if (event.key === 'Tab') {
if (
this.$.list.lastVisibleIndex === this._lastIndexValue ||
this.$.list.lastVisibleIndex === this._lastIndexValue - 1
) {
this.$.list.scrollTop = 0;
}
}
}

_lastIndexChanged(lastIndex) {
this._lastIndexValue = lastIndex;
}

// WEBUI-159: Check if there are more items in viewport than the ones set by the provider and load them.
Expand Down Expand Up @@ -266,4 +292,4 @@ import { PageProviderDisplayBehavior } from '../nuxeo-page-provider-display-beha

customElements.define(DataGrid.is, DataGrid);
Nuxeo.DataGrid = DataGrid;
}
}

0 comments on commit 8c6e8d1

Please sign in to comment.