From cb79b216ce4dd16049f961f574e1444b85ff45b7 Mon Sep 17 00:00:00 2001 From: arditdomi <32884230+arditdomi@users.noreply.github.com> Date: Wed, 8 Sep 2021 12:14:08 +0100 Subject: [PATCH] =?UTF-8?q?[ACA-4310]=20-=20Show=20the=20breadcrumb=20even?= =?UTF-8?q?=20for=20invalid=20selections=20in=20searc=E2=80=A6=20(#7241)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ACA-4310] - Show the breadcrumb even for invalid selections in search results * Empty commit Co-authored-by: Ardit Domi --- ...ontent-node-selector-panel.component.spec.ts | 17 ++++++++++++++++- .../content-node-selector-panel.component.ts | 8 +++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts index a192879c0d..eef77df6d7 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.spec.ts @@ -269,7 +269,7 @@ describe('ContentNodeSelectorPanelComponent', () => { }); - it('should show the breadcrumb for the selected node when search results are displayed', async () => { + it('should show the breadcrumb in search results for a valid node selection', async () => { searchQueryBuilderService.userQuery = 'mock-search-term'; searchQueryBuilderService.update(); triggerSearchResults(fakeResultSetPaging); @@ -283,6 +283,21 @@ describe('ContentNodeSelectorPanelComponent', () => { expect(breadcrumb.componentInstance.folderNode.path).toBe(chosenNode.path); }); + it('should show the breadcrumb in search results even for an invalid node selection', async () => { + component.isSelectionValid = (node: Node) => node.isFile; + searchQueryBuilderService.userQuery = 'mock-search-term'; + searchQueryBuilderService.update(); + triggerSearchResults(fakeResultSetPaging); + + const chosenNode = new Node({ path: { elements: ['fake-path'] }, isFile: false, isFolder: true }); + component.onCurrentSelection([{ entry: chosenNode }]); + fixture.detectChanges(); + + const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent)); + expect(breadcrumb).not.toBeNull(); + expect(breadcrumb.componentInstance.folderNode.path).toBe(chosenNode.path); + }); + it('should NOT show the breadcrumb for the selected node when not on search results list', async () => { triggerSearchResults(fakeResultSetPaging); fixture.detectChanges(); diff --git a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts index a8076730d0..2600e378c7 100644 --- a/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts +++ b/lib/content-services/src/lib/content-node-selector/content-node-selector-panel.component.ts @@ -248,7 +248,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { showingSearchResults: boolean = false; loadingSearchResults: boolean = false; inDialog: boolean = false; - _chosenNode: Node [] = null; + _chosenNode: Node[] = null; + selectionWithoutValidation: Node[] = null; folderIdToShow: string | null = null; breadcrumbFolderTitle: string | null = null; startSiteGuid: string | null = null; @@ -454,8 +455,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { get breadcrumbFolderNode(): Node | null { let folderNode: Node; - if (this.showingSearchResults && this.chosenNode) { - folderNode = this.chosenNode[0]; + if (this.showingSearchResults && this.selectionWithoutValidation?.length) { + folderNode = this.selectionWithoutValidation[0]; } else { folderNode = this.documentList.folderNode; } @@ -629,6 +630,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy { onCurrentSelection(nodesEntries: NodeEntry[]): void { const validNodesEntity = nodesEntries.filter((node) => this.isSelectionValid(node.entry)); this.chosenNode = validNodesEntity.map((node) => node.entry); + this.selectionWithoutValidation = nodesEntries.map(node => node.entry); } setTitleIfCustomSite(site: SiteEntry) {