From 629109ff42080914b12a12f3fdea8ff99cd28a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=AD=E5=B3=B6=20=E6=8B=93=E5=93=89?= Date: Tue, 29 Nov 2022 18:13:08 +0900 Subject: [PATCH 1/4] Enable keyfilter only for keydown, keyup, and keypress. --- src/core/action_descriptor.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/action_descriptor.ts b/src/core/action_descriptor.ts index a6604733..b18b680c 100644 --- a/src/core/action_descriptor.ts +++ b/src/core/action_descriptor.ts @@ -44,13 +44,21 @@ const descriptorPattern = /^(?:(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?) export function parseActionDescriptorString(descriptorString: string): Partial { const source = descriptorString.trim() const matches = source.match(descriptorPattern) || [] + let eventName = matches[1]; + let keyFilter = matches[2]; + + if (keyFilter && !['keydown', 'keyup', 'keypress'].includes(eventName)) { + eventName += keyFilter; + keyFilter = ''; + } + return { eventTarget: parseEventTarget(matches[3]), - eventName: matches[1], + eventName, eventOptions: matches[6] ? parseEventOptions(matches[6]) : {}, identifier: matches[4], methodName: matches[5], - keyFilter: matches[2], + keyFilter, } } From ca1146bababd171c4f5c5f989981bbbe468c9304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=AD=E5=B3=B6=20=E6=8B=93=E5=93=89?= Date: Tue, 29 Nov 2022 18:15:58 +0900 Subject: [PATCH 2/4] Fixed a bug in restoring event names --- src/core/action_descriptor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/action_descriptor.ts b/src/core/action_descriptor.ts index b18b680c..37b5d173 100644 --- a/src/core/action_descriptor.ts +++ b/src/core/action_descriptor.ts @@ -48,7 +48,7 @@ export function parseActionDescriptorString(descriptorString: string): Partial Date: Tue, 29 Nov 2022 18:26:52 +0900 Subject: [PATCH 3/4] add test --- .../modules/core/action_keyboard_filter_tests.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tests/modules/core/action_keyboard_filter_tests.ts b/src/tests/modules/core/action_keyboard_filter_tests.ts index da9252e3..64a9303c 100644 --- a/src/tests/modules/core/action_keyboard_filter_tests.ts +++ b/src/tests/modules/core/action_keyboard_filter_tests.ts @@ -21,6 +21,7 @@ export default class ActionKeyboardFilterTests extends LogControllerTestCase {