diff --git a/src/view/TabButton.tsx b/src/view/TabButton.tsx index e0f7a744..6f58739c 100755 --- a/src/view/TabButton.tsx +++ b/src/view/TabButton.tsx @@ -81,7 +81,8 @@ export const TabButton = (props: ITabButtonProps) => { return false; }; - const onClose = (event: React.MouseEvent) => { + const onClose = (event: React.MouseEvent) => { + event.preventDefault(); if (isClosable()) { layout.doAction(Actions.deleteTab(node.getId())); } else { @@ -89,7 +90,11 @@ export const TabButton = (props: ITabButtonProps) => { } }; - const onCloseMouseDown = (event: React.MouseEvent | React.TouchEvent) => { + const onCloseMouseDown = (event: React.MouseEvent | React.TouchEvent) => { + event.stopPropagation(); + }; + + const onCloseKeyDown = (event: React.KeyboardEvent) => { event.stopPropagation(); }; @@ -183,25 +188,37 @@ export const TabButton = (props: ITabButtonProps) => { if (node.isEnableClose() && !isStretch) { const closeTitle = layout.i18nName(I18nLabel.Close_Tab); renderState.buttons.push( -
+ onTouchStart={onCloseMouseDown} + onKeyDown={onCloseKeyDown}> {(typeof icons.close === "function") ? icons.close(node) : icons.close} -
+ ); } + const onKeyDown = (event: React.KeyboardEvent) => { + if (event.key === "Enter" || event.key === " ") { + event.preventDefault(); + onClick(); + } + }; + return (