Skip to content

fix(select): keep the active option when options are appended - #1847

Open
lskramarov wants to merge 2 commits into
mainfrom
fix/keep-the-active-option
Open

fix(select): keep the active option when options are appended#1847
lskramarov wants to merge 2 commits into
mainfrom
fix/keep-the-active-option

Conversation

@lskramarov

Copy link
Copy Markdown
Contributor

No description provided.

@lskramarov lskramarov self-assigned this Aug 5, 2026
@lskramarov lskramarov added the bug Something isn't working label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit a2f3870):

https://koobiq-next--prs-1847-hsycrq0f.web.app

(expires Sat, 08 Aug 2026 13:40:43 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c9e37e518febda70d0317d07e8ceb35ac43c534c

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

🚨 E2E tests failed

Review the report for details.


💡 Comment /approve-snapshots to approve snapshot changes.

@lskramarov
lskramarov force-pushed the fix/keep-the-active-option branch from 2c5f91f to 99083fb Compare August 5, 2026 12:37
@case ('success') {
@for (option of state.data; track option.id) {
<kbq-option [value]="option.id">
<kbq-option [value]="option">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ошибка все равно воспроизводится: https://koobiq-next--prs-1847-hsycrq0f.web.app/ru/components/select/examples#%D0%BF%D0%BE%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%87%D0%BD%D0%B0%D1%8F-%D0%B7%D0%B0%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D0%B0

Открыть, в поиске ввести 40
Выбрать опцию
Открыть выпадашку снова - Выбор вернется на элемент "#0"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates KbqSelect to avoid resetting the user’s current active (highlighted) option when new options are appended while the panel is open (e.g., infinite paging), and updates docs examples + tests to cover asynchronous option loading with preselected values.

Changes:

  • Adjust select’s key-manager activation logic to keep the active item stable during option list appends while open, and to avoid search-triggered highlight changes while the panel is still closed.
  • Update select paging/loading docs examples to use object values with compareWith, showPreselectedValues, and virtualOptionFactory (via KbqVirtualOption).
  • Add unit tests covering async option paging behavior and the “search emits while panel is closed” regression scenario.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/docs-examples/components/select/select-paging/select-paging-example.ts Updates paging example to bind option objects and enable virtual preselected rendering for unloaded pages.
packages/docs-examples/components/select/select-paging-error/select-paging-error-example.ts Same as paging example, but for the error-flow paging scenario.
packages/docs-examples/components/select/select-loading/select-loading-example.ts Updates loading example to support preselected virtual values and object-valued options.
packages/components/select/select.component.ts Prevents active option highlight from being reset on appended option chunks while the panel is open; refactors stale-active-item check.
packages/components/select/select.component.spec.ts Adds test coverage for async paging append behavior and search emissions while the panel is closed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1719 to +1724
/** Whether the key manager's active item is missing from the current options list. */
private isActiveItemStale(): boolean {
const activeItem = this.keyManager.activeItem as KbqOption | null;

return !activeItem || !this.options.toArray().includes(activeItem);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants