From 8c6e8d182d4805432021a44a8a3dc5ae89bf3071 Mon Sep 17 00:00:00 2001 From: rakeshkumar1019 Date: Tue, 5 Dec 2023 14:44:53 +0530 Subject: [PATCH] ELEMENTS-1697: update tabindex & lastindex in nuxeo-data-grid --- ui/nuxeo-data-grid/nuxeo-data-grid.js | 30 +++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/ui/nuxeo-data-grid/nuxeo-data-grid.js b/ui/nuxeo-data-grid/nuxeo-data-grid.js index 0756fa70b5..a82bb573bf 100644 --- a/ui/nuxeo-data-grid/nuxeo-data-grid.js +++ b/ui/nuxeo-data-grid/nuxeo-data-grid.js @@ -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. @@ -266,4 +292,4 @@ import { PageProviderDisplayBehavior } from '../nuxeo-page-provider-display-beha customElements.define(DataGrid.is, DataGrid); Nuxeo.DataGrid = DataGrid; -} +} \ No newline at end of file