mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-15 19:51:32 +03:00
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.
This commit is contained in:
parent
a31af39ca8
commit
eda453bbe5
1 changed files with 6 additions and 2 deletions
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue