taiga-family / taiga-ui

Angular UI Kit and components library for awesome people
https://taiga-ui.dev/
Apache License 2.0
3.22k stars 444 forks source link

🐞 - paste selection does not work as expected in virtual scroll ComboBox #5725

Open Gleb1nho opened 11 months ago

Gleb1nho commented 11 months ago

Playground Link

No response

Description

Options that were not previously displayed in virtual scroll ComboBox can not be correctly selected when option title (full-matched with some option name) is pasted from clipboard.

Steps to reproduce:

  1. Open https://taiga-ui.dev/components/combo-box#virtual
  2. Copy Zimbabwe to your clipboard
  3. Paste clipboard value to ComboBox
  4. Scroll to the end of list
  5. Zimbabwe is not selected

Expected behavior:

How to reproduce expected behavior:

  1. Copy Albania to your clipboard
  2. Paste clipboard value to ComboBox
  3. Albania is selected, checkmark is shown

P.S. Partial-matching clipboard value works as expected. E.g. Zimbabw or Albani trigger search/filtering as expected. When you paste (or manually search) such value, matching option would be selected correctly.

Angular version

14.0.0

Taiga UI version

3.46.0

Which browsers have you used?

Which operating systems have you used?

waterplea commented 9 months ago

The problem is because option only checks itself in ngOnInit, but virtual scroll reuses components, so it is the same component just with updated value and ngOnInit is not triggered: https://github.com/taiga-family/taiga-ui/blob/main/projects/kit/components/select-option/select-option.component.ts#L71 We will probably need a whole new mechanism to selecting matching values because in virtual scroll they are not all present so they cannot be queried. I will keep this in mind when implementing refactored combo box in 4.0