elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.7k stars 8.12k forks source link

When using a keyboard layout with dead keys Kibana's query string input will insert more matching characters than needed #136674

Open cleydyr opened 2 years ago

cleydyr commented 2 years ago

Kibana version: main

Elasticsearch version: main

Server OS version: macOS Monterrey 12.4

Browser version: Chrome Version 103.0.5060.114 (Official Build) (arm64)

Browser OS version:

Original install method (e.g. download page, yum, from source, etc.): From source

Describe the bug: When using a keyboard layout with dead keys Kibana's query string input will insert more matching characters than needed

Steps to reproduce:

  1. Set your keyboard layout to one with dead keys (I use US - International)
  2. In Discover, for example, in the query bar, enter double quotes (press " key [shift + '] once to activate the dead key, then press Space to enter the double quotes)

Expected behavior: The query bar should contain two double quotes characters: "". The cursor should be in position 2 (with position 1 being the beginning).

Current behavior: The query bar contains four double quotes characters: """". The cursor is in position 4 (with position 1 being the beginning)

Screenshots (if relevant): Not needed.

Errors in browser console (if relevant): N/A

Provide logs and/or server output (if relevant): N/A

Any additional context:

  1. Dead keys are not considered on the onKeyDown event handler in query_string_input.tsx, but they actually change the input
  2. When the actual double quote character is processed on the onKeyDown event and passed to the matchPairs function in match_pairs.ts, the function will change the query value as it should insert a matching character. But as the field value currently is "" it transforms it into """, as if it was closing the second double quote. The reason why the value on the text area is "" is because the first double quote is still there due to the pressing of the dead key and the second is inserted after the pressing of the space bar.
  3. Lastly, after the query is changed to """ somehow an extra inputChange event is fired by the text area (maybe because of the transformation of the dead key combination in double quotes finally occurs)?, and the query is changed from """ to """" as described above.
elasticmachine commented 2 years ago

Pinging @elastic/kibana-app-services (Team:AppServicesUx)

elasticmachine commented 1 year ago

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)