Bug 196272

Summary: [iOS] Should be able to dismiss picker or popover using the keyboard
Product: WebKit Reporter: Daniel Bates <dbates>
Component: WebKit Misc.Assignee: Daniel Bates <dbates>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, commit-queue, megan_gardner, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar, PlatformOnly
Version: WebKit Local Build   
Hardware: iPhone / iPad   
OS: iOS 12   
See Also: https://bugs.webkit.org/show_bug.cgi?id=196287
https://bugs.webkit.org/show_bug.cgi?id=158327
Bug Depends on:    
Bug Blocks: 190571, 195819, 196360    
Attachments:
Description Flags
Patch and layout test
none
Patch and layout test
none
Patch and layout test
none
Patch and layout test none

Description Daniel Bates 2019-03-26 14:57:13 PDT
Pressing the Escape key or Command + . should dismiss a picker or popover on iOS.
Comment 1 Daniel Bates 2019-03-26 14:57:18 PDT
<rdar://problem/48943170>
Comment 2 Daniel Bates 2019-03-26 21:15:21 PDT
Created attachment 366045 [details]
Patch and layout test
Comment 3 Daniel Bates 2019-03-28 10:36:49 PDT
Comment on attachment 366045 [details]
Patch and layout test

View in context: https://bugs.webkit.org/attachment.cgi?id=366045&action=review

> Source/WebKit/UIProcess/ios/forms/WKFormPeripheralBase.mm:75
> +    UIPhysicalKeyboardEvent *keyEvent = (UIPhysicalKeyboardEvent *)event;

AccessoryDone can be called multiple times. Doesn't cause an issue, but would be better to only call it once. Moreover, control may want want to distinguish between key events when its UI is presented vs key events when its UI is not on screen (e.g. <select> still supports typeahead and arrow keys even when its picker/popover is not on screen). To support this, will add @property (nonatomic, readonly) editing; <--- kinda don't like this name, went with it to match naming of beginEditing and endEditing and since I toggle YES/NO for _editing in these functions. We will early return before this line if !_editing.
Comment 4 Daniel Bates 2019-03-28 11:06:46 PDT
Created attachment 366184 [details]
Patch and layout test
Comment 5 Daniel Bates 2019-03-28 11:14:32 PDT
Comment on attachment 366184 [details]
Patch and layout test

View in context: https://bugs.webkit.org/attachment.cgi?id=366184&action=review

> LayoutTests/fast/forms/ios/dismiss-picker-using-keyboard.html:72
> +            UIHelper.keyDown("escape");

This should be:

UIHelper.keyDown(keyCommand.key, modifiers=keyCommand.modifiers);
Comment 6 Daniel Bates 2019-03-28 11:17:47 PDT
(In reply to Daniel Bates from comment #5)
> Comment on attachment 366184 [details]
> Patch and layout test
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=366184&action=review
> 
> > LayoutTests/fast/forms/ios/dismiss-picker-using-keyboard.html:72
> > +            UIHelper.keyDown("escape");
> 
> This should be:
> 
> UIHelper.keyDown(keyCommand.key, modifiers=keyCommand.modifiers);

Python on the 🧠. Not likely valid JS, yet:

UIHelper.keyDown(keyCommand.key, keyCommand.modifiers);
Comment 7 Daniel Bates 2019-03-28 11:19:51 PDT
Created attachment 366186 [details]
Patch and layout test
Comment 8 Daniel Bates 2019-03-28 15:28:23 PDT
Created attachment 366216 [details]
Patch and layout test
Comment 9 WebKit Commit Bot 2019-04-03 10:06:11 PDT
Comment on attachment 366216 [details]
Patch and layout test

Clearing flags on attachment: 366216

Committed r243808: <https://trac.webkit.org/changeset/243808>
Comment 10 WebKit Commit Bot 2019-04-03 10:06:13 PDT
All reviewed patches have been landed.  Closing bug.