From 078b21cff518efd353878b84d2152be46303b257 Mon Sep 17 00:00:00 2001 From: Shimada Takayuki Date: Sun, 13 Aug 2023 16:36:04 +0900 Subject: [PATCH] Add support for key events with autocomplete in Chrome In Google Chrome, when a text field has focus and an input suggestion is confirmed, a `keydown` event is fired. However, the event interface is not a `KeyboardEvent`, which causes the event handler to fail to determine whether it should be called. This change adds a test to ensure that the event handler is called correctly in this scenario. --- src/core/binding.ts | 8 ++++++++ src/tests/modules/core/action_keyboard_filter_tests.ts | 8 ++++++++ .../modules/core/action_params_case_insensitive_tests.ts | 2 +- src/tests/modules/core/action_params_tests.ts | 2 +- src/tests/modules/core/action_tests.ts | 4 ++-- src/tests/modules/core/event_options_tests.ts | 8 ++++---- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/core/binding.ts b/src/core/binding.ts index 33958667..b5dab5fd 100644 --- a/src/core/binding.ts +++ b/src/core/binding.ts @@ -86,6 +86,14 @@ export class Binding { private willBeInvokedByEvent(event: Event): boolean { const eventTarget = event.target + if ( + !(event instanceof KeyboardEvent) && + event instanceof Event && + (event.type === "keydown" || event.type === "keyup") + ) { + return false + } + if (event instanceof KeyboardEvent && this.action.shouldIgnoreKeyboardEvent(event)) { return false } diff --git a/src/tests/modules/core/action_keyboard_filter_tests.ts b/src/tests/modules/core/action_keyboard_filter_tests.ts index 64a9303c..bd1fdb7d 100644 --- a/src/tests/modules/core/action_keyboard_filter_tests.ts +++ b/src/tests/modules/core/action_keyboard_filter_tests.ts @@ -22,6 +22,7 @@ export default class ActionKeyboardFilterTests extends LogControllerTestCase {