From ac3310d23fa0367b6130a4b05fe41192410fadb3 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Thu, 9 Nov 2017 14:06:50 +0000 Subject: Suppress propagation for keyup events when we have for keydown events --- lib/dom_utils.coffee | 7 +++++-- lib/handler_stack.coffee | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index d8a5d203..95b9f4b3 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -344,7 +344,7 @@ DomUtils = consumeKeyup: do -> handlerId = null - (event, callback = null) -> + (event, callback = null, suppressPropagation) -> unless event.repeat handlerStack.remove handlerId if handlerId? code = event.code @@ -353,7 +353,10 @@ DomUtils = keyup: (event) -> return handlerStack.continueBubbling unless event.code == code @remove() - DomUtils.suppressEvent event + if suppressPropagation + DomUtils.suppressPropagation event + else + DomUtils.suppressEvent event handlerStack.continueBubbling # We cannot track keyup events if we lose the focus. blur: (event) -> diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee index 646ddfbd..a43fc356 100644 --- a/lib/handler_stack.coffee +++ b/lib/handler_stack.coffee @@ -57,7 +57,10 @@ class HandlerStack if result == @passEventToPage return true else if result == @suppressPropagation - DomUtils.suppressPropagation event + if type == "keydown" + DomUtils.consumeKeyup event, null, true + else + DomUtils.suppressPropagation event return false else if result == @restartBubbling return @bubbleEvent type, event -- cgit v1.2.3