Skip to content

Commit 9094584

Browse files
committed
Fix some a11y issues with the default node renderer
1 parent 497ff5a commit 9094584

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/node-renderer-default.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ const NodeRendererDefault = ({
6868
<div style={{ height: '100%' }}>
6969
{toggleChildrenVisibility && node.children && node.children.length > 0 && (
7070
<div>
71-
<div
71+
<button
72+
aria-label={node.expanded ? 'Collapse' : 'Expand'}
7273
className={node.expanded ? styles.collapseButton : styles.expandButton}
7374
style={{ left: -0.5 * scaffoldBlockPxWidth }}
7475
onClick={() => toggleChildrenVisibility({node, path, treeIndex})}

src/node-renderer-default.scss

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ $row-padding: 10px;
184184
line-height: 1;
185185
}
186186

187-
.visibilityToggleButton {
187+
.collapseButton, .expandButton {
188+
appearance: none;
189+
border: none;
188190
position: absolute;
189191
border-radius: 100%;
190192
box-shadow: 0 0 0 1px #000;
@@ -194,6 +196,11 @@ $row-padding: 10px;
194196
transform: translateY(-50%) translateX(-50%);
195197
cursor: pointer;
196198

199+
&:focus {
200+
outline: none;
201+
box-shadow: 0 0 0 1px #000, 0 0 1px 3px #83BEF9;
202+
}
203+
197204
&:hover:not(:active) {
198205
background-size: 24px;
199206
height: 20px;
@@ -202,12 +209,10 @@ $row-padding: 10px;
202209
}
203210

204211
.collapseButton {
205-
@extend .visibilityToggleButton;
206212
background: #FFF url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCI+PGNpcmNsZSBjeD0iOSIgY3k9IjkiIHI9IjgiIGZpbGw9IiNGRkYiLz48ZyBzdHJva2U9IiM5ODk4OTgiIHN0cm9rZS13aWR0aD0iMS45IiA+PHBhdGggZD0iTTQuNSA5aDkiLz48L2c+Cjwvc3ZnPg==') no-repeat center;
207213
}
208214

209215
.expandButton {
210-
@extend .visibilityToggleButton;
211216
background: #FFF url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCI+PGNpcmNsZSBjeD0iOSIgY3k9IjkiIHI9IjgiIGZpbGw9IiNGRkYiLz48ZyBzdHJva2U9IiM5ODk4OTgiIHN0cm9rZS13aWR0aD0iMS45IiA+PHBhdGggZD0iTTQuNSA5aDkiLz48cGF0aCBkPSJNOSA0LjV2OSIvPjwvZz4KPC9zdmc+') no-repeat center;
212217
}
213218

0 commit comments

Comments
 (0)