Small fixes for LeftPaneDialog

This commit is contained in:
Fedor Indutny 2021-10-05 07:22:41 -07:00 committed by GitHub
parent 87ea95735e
commit 4d180a26fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 5 deletions

View file

@ -59,6 +59,17 @@ export const LeftPaneDialog: React.FC<PropsType> = ({
onClick?.();
};
const onKeyDownWrap = (e: React.KeyboardEvent) => {
if (e.key !== 'Enter' && e.key !== ' ') {
return;
}
e.preventDefault();
e.stopPropagation();
onClick?.();
};
const onCloseWrap = (e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
@ -109,6 +120,7 @@ export const LeftPaneDialog: React.FC<PropsType> = ({
const className = classNames([
BASE_CLASS_NAME,
type === undefined ? undefined : `${BASE_CLASS_NAME}--${type}`,
onClick === undefined ? undefined : `${BASE_CLASS_NAME}--clickable`,
]);
const content = (
@ -128,16 +140,17 @@ export const LeftPaneDialog: React.FC<PropsType> = ({
if (onClick) {
return (
<button
<div
className={className}
type="button"
role="button"
onClick={onClickWrap}
onKeyDown={onKeyDownWrap}
aria-label={clickLabel}
title={hoverText}
tabIndex={0}
>
{content}
</button>
</div>
);
}