Bug 297091

Summary: [WPE] <dialog> does not close if "Escape" is pressed inside a "contenteditable" element
Product: WebKit Reporter: Yury Semikhatsky <yurys>
Component: WPE WebKitAssignee: Diego Pino <dpino>
Status: RESOLVED FIXED    
Severity: Normal CC: aperez, bugs-noreply, cgarcia, dpino, spena
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Linux   
See Also: https://bugs.webkit.org/show_bug.cgi?id=294752
Attachments:
Description Flags
test page none

Yury Semikhatsky
Reported 2025-08-07 17:45:24 PDT
Steps to reproduce: 1. Open attached page 2. Put focus inside the contenteditable field 3. Press "Escape" Expected: The dialog is closed. Actual: The dialog stays open. Works fine on GTK and other platforms. Originally reported in Playwright: https://github.com/microsoft/playwright/issues/36727
Attachments
test page (550 bytes, text/html)
2025-08-07 17:45 PDT, Yury Semikhatsky
no flags
Yury Semikhatsky
Comment 1 2025-08-07 17:45:46 PDT
Created attachment 476302 [details] test page
Tim Nguyen (:ntim)
Comment 2 2025-08-08 00:16:42 PDT
*** Bug 297090 has been marked as a duplicate of this bug. ***
Tim Nguyen (:ntim)
Comment 3 2025-08-08 00:16:45 PDT
*** Bug 297089 has been marked as a duplicate of this bug. ***
Carlos Garcia Campos
Comment 4 2025-08-09 00:09:46 PDT
If this only happens in MiniBroweser this regressed in 298279@main because Escape is always claimed to be handled by MiniBrowser so the key event is not passed to webkit.
Diego Pino
Comment 5 2025-08-11 04:21:12 PDT
(In reply to Carlos Garcia Campos from comment #4) > If this only happens in MiniBroweser this regressed in 298279@main because > Escape is always claimed to be handled by MiniBrowser so the key event is > not passed to webkit. I can reproduce the bug using 298278@main. On that build, I noticed I can close the dialog if I press "Ctrl + ESC" or "Shift + ESC". However, that doesn't work on 298279@main. So there are two issues here. In one hand, 298279@main should not treat ESC as a WPE MiniBrowser shortcut, and let the WebProcessUI see that key stroke (I think replacing `return TRUE` for `return FALSE` in https://github.com/WebKit/WebKit/blob/main/Tools/MiniBrowser/wpe/main.cpp#L242 should fix that). Then, there's the issue on why in WPE `WPE_KEY_Escape` is emitted only when Ctrl or Shit are pressed in combination with ESC.
Yury Semikhatsky
Comment 6 2025-08-11 11:03:09 PDT
FWIW, Playwright 1.54.1 where the user reported the issue is shipped with WebKit https://commits.webkit.org/297047@main, which is a commit from July 7. So I don't think this is recently introduced bug.
Diego Pino
Comment 7 2025-08-12 01:17:25 PDT
I figured out what is the issue. When ESC key is pressed in WPE, they key is interpreted as "Cancel" because of https://github.com/WebKit/WebKit/blob/main/Source/WebKit/WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp#L108. On the other hand, in WebKitGTK, when ESC key is pressed the string returned is null. The function call sequence is the following: - Source/WebCore/page/EventHandler.cpp:internalKeyEvent - Source/WebCore/platform/libwpe/PlatformKeyboardEventLibWPE.cpp:disambiguateKeyDownEvent - Source/WebKit/WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp:handleKeyDown - Source/WebKit/WebProcess/WebCoreSupport/wpe/WebEditorClientWPE.cpp:interpretKeyEvent Since `VK_ESCAPE` is a member of `keyDownEntries`, function `interpretKeyEvent` returns a value, and because of that `handleKeyDown` sets the event as `defaultHandled`. And since the keydown event was defaultHandled, `EventHandler` exists earlier here: https://github.com/WebKit/WebKit/blob/main/Source/WebCore/page/EventHandler.cpp#L4092 Removing VK_ESCAPE from keyDownEntries fixes the issue.
Diego Pino
Comment 8 2025-08-12 02:31:23 PDT
EWS
Comment 9 2025-08-12 06:37:25 PDT
Committed 298562@main (68ee5059655d): <https://commits.webkit.org/298562@main> Reviewed commits have been landed. Closing PR #49265 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.