File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
packages/components/src/Tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -236,4 +236,36 @@ describe('Tree', () => {
236236 expect ( screen . getByTestId ( 'icon' ) ) . toHaveStyle ( 'color: #939ba5' )
237237 } )
238238 } )
239+
240+ describe ( 'aria roles' , ( ) => {
241+ test ( 'selected Trees have aria-selected=true' , ( ) => {
242+ renderWithTheme (
243+ < Tree
244+ color = "calculation"
245+ selected
246+ label = "Whatever"
247+ icon = { < Science data-testid = "icon" /> }
248+ />
249+ )
250+ expect ( screen . getAllByRole ( 'treeitem' ) [ 0 ] ) . toHaveAttribute (
251+ 'aria-selected' ,
252+ 'true'
253+ )
254+ } )
255+
256+ test ( 'current Trees have aria-current=true' , ( ) => {
257+ renderWithTheme (
258+ < Tree
259+ color = "calculation"
260+ current
261+ label = "Whatever"
262+ icon = { < Science data-testid = "icon" /> }
263+ />
264+ )
265+ expect ( screen . getAllByRole ( 'treeitem' ) [ 0 ] ) . toHaveAttribute (
266+ 'aria-current' ,
267+ 'true'
268+ )
269+ } )
270+ } )
239271} )
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ const TreeLayout: FC<TreeProps> = ({
4747 border : propsBorder ,
4848 children,
4949 className,
50+ current,
5051 density : propsDensity ,
5152 detail : propsDetail ,
5253 disabled,
@@ -141,6 +142,8 @@ const TreeLayout: FC<TreeProps> = ({
141142 const indicatorColor = disabled ? 'text1' : 'text5'
142143 const innerAccordion = (
143144 < Accordion
145+ aria-current = { current }
146+ aria-selected = { selected }
144147 content = {
145148 < List density = { density } role = "group" windowing = "none" >
146149 { children }
@@ -173,6 +176,7 @@ const TreeLayout: FC<TreeProps> = ({
173176 branchFontWeight = { branchFontWeight }
174177 color = { color }
175178 className = { className }
179+ current = { current }
176180 depth = { depth }
177181 disabled = { disabled }
178182 dividers = { dividers }
You can’t perform that action at this time.
0 commit comments