Skip to content

Feature/preselect first search result item in assistant - #5656

Merged
dtslvr merged 9 commits into
ghostfolio:mainfrom
yashranaway:feature/assistant-preselect-first-item
Oct 4, 2025
Merged

dtslvr merged 9 commits into
ghostfolio:mainfrom
yashranaway:feature/assistant-preselect-first-item

Conversation

@yashranaway

Copy link
Copy Markdown
Contributor

Auto-preselect first search result in assistant

Fixes : #4902

What: Automatically preselects the first search result when assistant results are displayed, allowing users to press Enter immediately without needing arrow keys first.

Why: Improves UX by reducing keystrokes - users can now type and immediately press Enter to activate the first result.

How:

  • Added getFirstSearchResultItem() to determine first item by priority (Quick Links → Accounts → Holdings → Asset Profiles)
  • Added preselectFirstItem() with 100ms debouncing to auto-focus first result
  • Integrated with existing FocusKeyManager for seamless keyboard navigation

Testing: Manual testing confirmed automatic preselection works correctly with immediate Enter key activation.

@yashranaway

Copy link
Copy Markdown
Contributor Author

hey @dtslvr , please let me if you need anything update. thanks

@dtslvr dtslvr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, @yashranaway! 😎
I have reviewed your changes and added a few comments.

Could you also add a changelog item? Thanks.

this.searchResults = searchResults;
this.changeDetectorRef.markForCheck();

// Trigger preselection of first item

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment

}

public ngOnDestroy() {
// Clear preselection timeout

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment

'TAG'
];
private keyManager: FocusKeyManager<GfAssistantListItemComponent>;
private preselectionTimeout: any;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a type instead of any

private preselectionTimeout: any;
private unsubscribeSubject = new Subject<void>();

private readonly PRESELECTION_DELAY = 100;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move up (before filterTypes)

* Gets the first search result item based on priority order:
* Quick Links → Accounts → Holdings → Asset Profiles
*/
private getFirstSearchResultItem(): ISearchResultItem | null {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove return value type

/**
* Preselects the first search result item with debouncing
*/
private preselectFirstItem(): void {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove void

@yashranaway

Copy link
Copy Markdown
Contributor Author

right on it

@yashranaway
yashranaway requested a review from dtslvr October 4, 2025 14:37

@dtslvr dtslvr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, @yashranaway! 👍🏻

Could you please address all open comments?

if (this.preselectionTimeout) {
clearTimeout(this.preselectionTimeout);
}
this.unsubscribeSubject.next();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add line break

Comment thread CHANGELOG.md Resolved
Comment thread CHANGELOG.md Resolved
'SYMBOL',
'TAG'
];
private keyManager: FocusKeyManager<GfAssistantListItemComponent>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep here!

'TAG'
];
private keyManager: FocusKeyManager<GfAssistantListItemComponent>;
private unsubscribeSubject = new Subject<void>();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep here!

@yashranaway
yashranaway requested a review from dtslvr October 4, 2025 16:25

@dtslvr dtslvr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made some final adjustments. Ready to merge now.

@dtslvr dtslvr changed the title feat: auto-preselect first search result in assistant Feature/preselect first search result item in assistant Oct 4, 2025
@yashranaway

Copy link
Copy Markdown
Contributor Author

thank you @dtslvr

@dtslvr

dtslvr commented Oct 4, 2025

Copy link
Copy Markdown
Member

thank you @dtslvr

Thank you, likewise. And congrats on your first contribution, @yashranaway 🙌🏻

@dtslvr
dtslvr merged commit 2248eb7 into ghostfolio:main Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preselect first search result item in assistant

2 participants