From eda453bbe5aac4e16896df473ee9faad045352d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20V=C3=A1gner?= Date: Tue, 5 Dec 2017 23:23:40 +0100 Subject: [PATCH] Fixed an issue where pressing enter key to activate the AccessibleButton was also activating normal button that might just have received the system focus as a result of the key press and the other way round. The most obvious occurence of this issue is that dialogs were reappearing when dismissed by pressing the enter key. --- src/components/views/elements/AccessibleButton.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/views/elements/AccessibleButton.js b/src/components/views/elements/AccessibleButton.js index 794e0a4dd7..59c4b99798 100644 --- a/src/components/views/elements/AccessibleButton.js +++ b/src/components/views/elements/AccessibleButton.js @@ -27,8 +27,12 @@ import React from 'react'; export default function AccessibleButton(props) { const {element, onClick, children, ...restProps} = props; restProps.onClick = onClick; - restProps.onKeyUp = function(e) { - if (e.keyCode == 13 || e.keyCode == 32) return onClick(e); + restProps.onKeyDown = function(e) { + if (e.keyCode == 13 || e.keyCode == 32) { + e.stopPropagation(); + e.preventDefault(); + return onClick(e); + } }; restProps.tabIndex = restProps.tabIndex || "0"; restProps.role = "button";