Skip to content

Commit

Permalink
fix: Top 컴포넌트 접근성 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
soi-ha committed Oct 16, 2024
1 parent 12701ed commit 6216dec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/src/components/Design/components/Top/Line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function Line({text, emphasize = []}: Props) {
size="subTitle"
textColor={emphasize.includes(text) ? 'black' : 'gray'}
style={{whiteSpace: 'pre'}}
aria-hidden={true}
>
{`${text}`}
</Text>
Expand Down
16 changes: 16 additions & 0 deletions client/src/components/Design/components/Top/Top.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @jsxImportSource @emotion/react */
import {css} from '@emotion/react';
import {useEffect, useState} from 'react';
import React from 'react';

import Line from './Line';
import EditableLine from './EditableLine';
Expand All @@ -8,12 +10,26 @@ Top.Line = Line;
Top.EditableLine = EditableLine;

export default function Top({children}: React.PropsWithChildren) {
const [childrenTexts, setChildrenTexts] = useState<string[]>([]);

useEffect(() => {
const collectedTexts: string[] = [];
React.Children.forEach(children, child => {
if (React.isValidElement(child) && child.type === Top.Line) {
collectedTexts.push(child.props.text);
}
});
setChildrenTexts(collectedTexts);
}, [children]);

return (
<div
css={css`
display: flex;
flex-direction: column;
`}
aria-label={childrenTexts.join(' ')}
tabIndex={0}
>
{children}
</div>
Expand Down

0 comments on commit 6216dec

Please sign in to comment.