Browse Source

chore: update changelog for version 2.206.0 and implement auto-preselect for first search result in assistant

pull/5656/head
adityagarud 3 months ago
parent
commit
f2a2fa1bd7
  1. 6
      CHANGELOG.md
  2. 24
      libs/ui/src/lib/assistant/assistant.component.ts

6
CHANGELOG.md

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 2.206.0 - 2025-01-27
### Added
- Auto-preselect first search result in assistant for improved keyboard navigation
## 2.205.0 - 2025-10-01 ## 2.205.0 - 2025-10-01
### Changed ### Changed

24
libs/ui/src/lib/assistant/assistant.component.ts

@ -169,6 +169,12 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
}; };
public tags: Filter[] = []; public tags: Filter[] = [];
private keyManager: FocusKeyManager<GfAssistantListItemComponent>;
private preselectionTimeout: ReturnType<typeof setTimeout>;
private unsubscribeSubject = new Subject<void>();
private readonly PRESELECTION_DELAY = 100;
private filterTypes: Filter['type'][] = [ private filterTypes: Filter['type'][] = [
'ACCOUNT', 'ACCOUNT',
'ASSET_CLASS', 'ASSET_CLASS',
@ -176,11 +182,6 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
'SYMBOL', 'SYMBOL',
'TAG' 'TAG'
]; ];
private keyManager: FocusKeyManager<GfAssistantListItemComponent>;
private preselectionTimeout: any;
private unsubscribeSubject = new Subject<void>();
private readonly PRESELECTION_DELAY = 100;
public constructor( public constructor(
private adminService: AdminService, private adminService: AdminService,
@ -347,10 +348,8 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
.subscribe({ .subscribe({
next: (searchResults) => { next: (searchResults) => {
this.searchResults = searchResults; this.searchResults = searchResults;
this.changeDetectorRef.markForCheck();
// Trigger preselection of first item
this.preselectFirstItem(); this.preselectFirstItem();
this.changeDetectorRef.markForCheck();
}, },
error: (error) => { error: (error) => {
console.error('Assistant search stream error:', error); console.error('Assistant search stream error:', error);
@ -591,11 +590,9 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
} }
public ngOnDestroy() { public ngOnDestroy() {
// Clear preselection timeout
if (this.preselectionTimeout) { if (this.preselectionTimeout) {
clearTimeout(this.preselectionTimeout); clearTimeout(this.preselectionTimeout);
} }
this.unsubscribeSubject.next(); this.unsubscribeSubject.next();
this.unsubscribeSubject.complete(); this.unsubscribeSubject.complete();
} }
@ -610,7 +607,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
* Gets the first search result item based on priority order: * Gets the first search result item based on priority order:
* Quick Links Accounts Holdings Asset Profiles * Quick Links Accounts Holdings Asset Profiles
*/ */
private getFirstSearchResultItem(): ISearchResultItem | null { private getFirstSearchResultItem() {
// Priority order: Quick Links → Accounts → Holdings → Asset Profiles // Priority order: Quick Links → Accounts → Holdings → Asset Profiles
if (this.searchResults.quickLinks?.length > 0) { if (this.searchResults.quickLinks?.length > 0) {
return this.searchResults.quickLinks[0]; return this.searchResults.quickLinks[0];
@ -624,13 +621,14 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
if (this.searchResults.assetProfiles?.length > 0) { if (this.searchResults.assetProfiles?.length > 0) {
return this.searchResults.assetProfiles[0]; return this.searchResults.assetProfiles[0];
} }
return null; return null;
} }
/** /**
* Preselects the first search result item with debouncing * Preselects the first search result item with debouncing
*/ */
private preselectFirstItem(): void { private preselectFirstItem() {
// Clear any existing timeout // Clear any existing timeout
if (this.preselectionTimeout) { if (this.preselectionTimeout) {
clearTimeout(this.preselectionTimeout); clearTimeout(this.preselectionTimeout);
@ -644,6 +642,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
} }
const firstItem = this.getFirstSearchResultItem(); const firstItem = this.getFirstSearchResultItem();
if (!firstItem) { if (!firstItem) {
return; return;
} }
@ -658,6 +657,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
// Get the currently focused item and apply focus styling // Get the currently focused item and apply focus styling
const currentFocusedItem = this.getCurrentAssistantListItem(); const currentFocusedItem = this.getCurrentAssistantListItem();
if (currentFocusedItem) { if (currentFocusedItem) {
currentFocusedItem.focus(); currentFocusedItem.focus();
} }

Loading…
Cancel
Save