vaadin / web-components

A set of high-quality standards based web components for enterprise web applications. Part of Vaadin 20+
https://vaadin.com/docs/latest/components
445 stars 83 forks source link

Cannot select item in Select component by pressing language specific keys #6581

Closed javier-godoy closed 10 months ago

javier-godoy commented 11 months ago

Description

When pressing a key in the Select component, the first element that starts with that letter is selected. However, that feature seems to work only for letters in the Latin Basic block.

When pressing a key that corresponds to other letters, such as Ñ (Uppercase Letter, Latin-1 Supplement, U+00D1) or Š (Uppercase Letter, Latin Extended-A, U+0160) no item is selected.

Note that these letters have dedicated key in some keyboard layouts (Ñ is a key in the Spanish layout andŠ is a key in the Slovenian layout).

Expected outcome

I would expect that the first item that begins with the pressed letter is selected.

Minimal reproducible example

String[] items = new String[] {"A", "Š", "C", "Č", "B", "Ž", "D", "N", "Ñ"};
Dialog dialog = new Dialog();
Select<String> select = new Select<>();
select.setItems(items);
dialog.add(select);
dialog.open();

Steps to reproduce

  1. Use a keyboard with Slovenian layout
  2. Open the dialog from the reproducible example
  3. Focus the select component and press Š
  4. Observe that no item was selected

Alternatively,

  1. Use a keyboard with Spanish layout
  2. Open the dialog from the reproducible example
  3. Focus the select component and press Ñ
  4. Observe that no item was selected

Environment

Vaadin version(s): 23.3.15, 24.1.10 OS: Windows 10

Browsers

Chrome

web-padawan commented 11 months ago

This looks similar to https://github.com/vaadin/web-components/issues/465 which has been fixed by changing the RegExp. Need to check why it doesn't work in this case.

web-padawan commented 10 months ago

Tested this with latest (24.3) and 23.3 branches and on MacOS it works fine:

https://github.com/vaadin/web-components/assets/10589913/dd5c4068-69cc-49e5-8c18-67c7166ce4f8 https://github.com/vaadin/web-components/assets/10589913/18712b75-1261-4ec5-b6f8-166f49ed3677
javier-godoy commented 10 months ago

Does it also work when clicking the select component, so that it opens the overlay before pressing Ñ? I've just tested in 23.3.27 and it doesn't.

image

web-padawan commented 10 months ago

Does it also work when clicking the select component, so that it opens the overlay before pressing Ñ

Thanks, now I can reproduce it. Here's the logic that should be updated, I will make a PR to fix it:

https://github.com/vaadin/web-components/blob/4e74838d6955213028ccb768bad15c434088bfe7/packages/a11y-base/src/list-mixin.js#L256