From f36fccd3efe80834a7ac169a498a8bd000875786 Mon Sep 17 00:00:00 2001 From: Laurent Nguyen Date: Tue, 10 Oct 2023 05:19:35 +0000 Subject: [PATCH] Auto-select first item in DocumentsTab. Fix selection highlighting (#1645) * Auto-select first document in documentsTab * Fix style row selection by making selector more specific --- less/documentDB.less | 14 +++++++------- src/Explorer/Tabs/DocumentsTab.ts | 29 +++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/less/documentDB.less b/less/documentDB.less index 976bd03fd..bdefc2dbd 100644 --- a/less/documentDB.less +++ b/less/documentDB.less @@ -1179,16 +1179,16 @@ menuQuickStart { } } -.gridRowSelected { +#tbodycontent tr.gridRowSelected { .active(); } -.gridRowSelected:hover { +#tbodycontent tr.gridRowSelected:hover { cursor: default; .hover(); } -.gridRowHighlighted { +#tbodycontent tr.gridRowHighlighted { border-style: dotted; border-width: 2px; } @@ -2576,9 +2576,10 @@ a:link { .querydropdown.placeholderVisible { font-style: italic; } -.querydropdown.placeholderVisible::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ +.querydropdown.placeholderVisible::placeholder { + /* Chrome, Firefox, Opera, Safari 10.1+ */ color: #767474; - opacity: 1; + opacity: 1; } .querydropdown:hover { @@ -2648,7 +2649,7 @@ a:link { .nav-tabs > li.active > .tabNavContentContainer > .tab_Content > .tabNavText { font-weight: bolder; - border-bottom: 2px solid rgba(0,120,212,1); + border-bottom: 2px solid rgba(0, 120, 212, 1); } .nav-tabs > li.active:focus > .tabNavContentContainer { @@ -3096,4 +3097,3 @@ a:link { background: white; height: 100%; } - diff --git a/src/Explorer/Tabs/DocumentsTab.ts b/src/Explorer/Tabs/DocumentsTab.ts index cd43ab29c..a62c1f416 100644 --- a/src/Explorer/Tabs/DocumentsTab.ts +++ b/src/Explorer/Tabs/DocumentsTab.ts @@ -346,6 +346,22 @@ export default class DocumentsTab extends TabsBase { return true; } + /** + * Query first page of documents + * Select and query first document and display content + */ + private async autoPopulateContent() { + // reset iterator + this._documentsIterator = this.createIterator(); + // load documents + await this.loadNextPage(); + + // Select first document and load content + if (this.documentIds().length > 0) { + this.documentIds()[0].click(); + } + } + public onShowFilterClick(): Q.Promise { this.isFilterCreated(true); this.isFilterExpanded(true); @@ -380,10 +396,7 @@ export default class DocumentsTab extends TabsBase { this.documentIds([]); try { - // reset iterator - this._documentsIterator = this.createIterator(); - // load documents - await this.loadNextPage(); + await this.autoPopulateContent(); // collapse filter this.appliedFilter(this.filterContent()); this.isFilterExpanded(false); @@ -406,6 +419,11 @@ export default class DocumentsTab extends TabsBase { this.queryAbortController.abort(); } + /** + * TODO Doesn't seem to be used: remove? + * @param clickedDocumentId + * @returns + */ public onDocumentIdClick(clickedDocumentId: DocumentId): Q.Promise { if (this.editorState() !== ViewModels.DocumentExplorerState.noDocumentSelected) { return Q(); @@ -624,8 +642,7 @@ export default class DocumentsTab extends TabsBase { if (!this._documentsIterator) { try { - this._documentsIterator = this.createIterator(); - await this.loadNextPage(); + await this.autoPopulateContent(); } catch (error) { if (this.onLoadStartKey != null && this.onLoadStartKey != undefined) { TelemetryProcessor.traceFailure(