Skip to content

Commit

Permalink
#205 feat: 타임블록 tab과 enter로 접근 가능하도록 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
namdaeun committed Aug 4, 2024
1 parent 050f880 commit db64404
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/page/archiving/index/ArchivingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ const ArchivingPage = () => {
setSelectedId(id);
};

const handleBlockClick = (e: React.MouseEvent<HTMLDivElement>, block: Block) => {
const handleBlockClick = (
e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>,
block: Block
) => {
e.stopPropagation();

e.currentTarget.scrollIntoView({
Expand Down
15 changes: 13 additions & 2 deletions src/page/archiving/index/component/TimeBlock/TimeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface TimeBlockProps extends HTMLAttributes<HTMLDivElement> {
floor: number;
blockType: string;
isSelected?: boolean;
onBlockClick: (e: React.MouseEvent<HTMLDivElement>) => void;
onBlockClick: (e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>) => void;
}

const TimeBlock = ({
Expand All @@ -30,7 +30,18 @@ const TimeBlock = ({

return (
/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
<div css={blockStyle(blockWidth, startPosition, floor, color, isSelected)} onClick={onBlockClick} {...props}>
<div
role="tab"
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.preventDefault();
onBlockClick(e);
}
}}
css={blockStyle(blockWidth, startPosition, floor, color, isSelected)}
onClick={onBlockClick}
{...props}>
{BLOCK_TYPE.find((icon) => icon.name === blockType)?.icon}
<span css={blockNameStyle}>{children}</span>
</div>
Expand Down

0 comments on commit db64404

Please sign in to comment.