Skip to content

Commit c86ea2b

Browse files
authored
fix(a11y): separate disclosure content from toggle button (freeCodeCamp#59286)
1 parent 173d87f commit c86ea2b

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

client/src/templates/Introduction/components/block-header.tsx

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,37 @@ function BlockHeader({
3434
blockIntroArr
3535
}: BlockHeaderProps): JSX.Element {
3636
return (
37-
<h3 className='block-grid-title'>
38-
<button
39-
aria-expanded={isExpanded ? 'true' : 'false'}
40-
aria-controls={`${blockDashed}-panel`}
41-
className='block-header'
42-
onClick={handleClick}
43-
>
44-
<span className='block-header-button-text map-title'>
45-
<CheckMark isCompleted={isCompleted} />
46-
{blockType && <BlockLabel blockType={blockType} />}
47-
<span>
48-
{blockTitle}
49-
<span className='sr-only'>, {courseCompletionStatus}</span>
37+
<>
38+
<h3 className='block-grid-title'>
39+
<button
40+
aria-expanded={isExpanded ? 'true' : 'false'}
41+
aria-controls={`${blockDashed}-panel`}
42+
className='block-header'
43+
onClick={handleClick}
44+
>
45+
<span className='block-header-button-text map-title'>
46+
<CheckMark isCompleted={isCompleted} />
47+
{blockType && <BlockLabel blockType={blockType} />}
48+
<span>
49+
{blockTitle}
50+
<span className='sr-only'>, {courseCompletionStatus}</span>
51+
</span>
52+
<DropDown />
5053
</span>
51-
<DropDown />
52-
</span>
53-
{isExpanded && !isEmpty(blockIntroArr) && (
54-
<BlockIntros intros={blockIntroArr as string[]} />
55-
)}
56-
{!isExpanded && !isCompleted && completedCount > 0 && (
57-
<div aria-hidden='true' className='progress-wrapper'>
58-
<div>
59-
<ProgressBar now={percentageCompleted} />
54+
{!isExpanded && !isCompleted && completedCount > 0 && (
55+
<div aria-hidden='true' className='progress-wrapper'>
56+
<div>
57+
<ProgressBar now={percentageCompleted} />
58+
</div>
59+
<span>{`${percentageCompleted}%`}</span>
6060
</div>
61-
<span>{`${percentageCompleted}%`}</span>
62-
</div>
63-
)}
64-
</button>
65-
</h3>
61+
)}
62+
</button>
63+
</h3>
64+
{isExpanded && !isEmpty(blockIntroArr) && (
65+
<BlockIntros intros={blockIntroArr as string[]} />
66+
)}
67+
</>
6668
);
6769
}
6870

client/src/templates/Introduction/intro.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ button.map-title {
337337
margin-bottom: 0;
338338
}
339339

340+
.block-grid .block-description {
341+
padding: 18px 15px;
342+
}
343+
340344
a.map-grid-item.challenge-completed {
341345
background: var(--highlight-background);
342346
position: relative;

0 commit comments

Comments
 (0)