Skip to content

Commit

Permalink
Small fixes for LeftPaneDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny-signal committed Oct 5, 2021
1 parent 87ea957 commit 4d180a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
6 changes: 4 additions & 2 deletions stylesheets/components/LeftPaneDialog.scss
Expand Up @@ -11,8 +11,6 @@
}

.LeftPaneDialog {
@include button-reset;

align-items: center;
background: $color-ultramarine;
color: $color-white;
Expand All @@ -23,6 +21,10 @@
user-select: none;
cursor: inherit;

&--clickable {
cursor: pointer;
}

&__container {
display: flex;
align-items: center;
Expand Down
19 changes: 16 additions & 3 deletions ts/components/LeftPaneDialog.tsx
Expand Up @@ -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();
Expand Down Expand Up @@ -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 = (
Expand All @@ -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>
);
}

Expand Down

0 comments on commit 4d180a2

Please sign in to comment.