Bug 141758 - Finding an option in a select element shouldn't be reset when the user types a space
Summary: Finding an option in a select element shouldn't be reset when the user types ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified OS X 10.10
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-02-18 09:21 PST by Adele Peterson
Modified: 2023-06-16 09:48 PDT (History)
10 users (show)

See Also:


Attachments
Test case (159 bytes, text/html)
2015-02-18 09:21 PST, Adele Peterson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adele Peterson 2015-02-18 09:21:35 PST
Created attachment 246820 [details]
Test case

Finding an option in a select element shouldn't be reset when the user types a space.

Steps to reproduce:
1) Load the attached test case
2) Hit tab twice to focus the select element
3) Type "United S"

When you hit the space, the search string is reset, and when you next type "S", "Spain" is selected.  I expect "United States" to be selected.

Firefox behaves correctly, Chrome matches our behavior.
Comment 1 Adele Peterson 2015-02-18 09:33:12 PST
rdar://problem/19875341
Comment 2 Adele Peterson 2015-02-22 21:12:09 PST
WebKit considers the event to be handled once the popup opens.  I played around with trying to call typeAheadFind before opening the menu, but that doesn't really help.  The searching WebKit does in the select element before the menu opens is separate from any searching that happens after the menu is open (which I think is handled by AppKit).  So even if WebKit's search string includes the space, it doesn't help because the AppKit menu doesn't know anything about the characters that were typed before the menu was opened.  So I think the challenge here is to find a way to pass this info along.
Comment 3 Abhijeet Kandalkar 2015-04-02 03:03:59 PDT
Related chromium issue :
https://code.google.com/p/chromium/issues/detail?id=473050
Comment 4 Ahmad Saleem 2022-09-18 03:27:53 PDT
I think this is added already here:

https://github.com/WebKit/WebKit/blob/5a8883c75f0a425515a601a4eb8de66e88ada97d/Source/WebCore/html/HTMLSelectElement.cpp#L1213

rniwa@webkit.org - Can you confirm? Thanks!
Comment 5 Ryosuke Niwa 2022-09-18 18:47:52 PDT
The issue still reproduces in Safari whereas Chrome & Firefox will select "United States" upon typing "united s". The space after "united" is opening the popup instead of changing the selection to "united states".
Comment 6 Ahmad Saleem 2023-06-16 09:48:02 PDT
Potential merge - https://src.chromium.org/viewvc/blink?view=revision&revision=193280

^ I merged locally with following changes:

< In HTMLSelectElement.cpp >

Line 1245:

if ((keyCode == ' ' && !m_typeAhead.hasActiveSession(&keyboardEvent)) || keyCode == '\r') {

in HTMLSelectElement::menuListDefaultEventHandler.

_______

< In TypeAhead.h >

    bool hasActiveSession(KeyboardEvent*);

_____

< In TypeAhead.cpp >


bool TypeAhead::hasActiveSession(KeyboardEvent* event)
{
    Seconds delta = event->timeStamp() - m_lastTypeTime;
    return delta <= typeAheadTimeout;
}

______


This compiles but it does not fixed attached testcase. :-(