Skip to content

Commit d072928

Browse files
cliftonmcintoshclaude
authored andcommitted
Improve chevron toggle accessibility using button element and aria-expanded
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bdc157f commit d072928

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

app/assets/stylesheets/pages/case_contacts.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@
148148

149149
.expand-toggle {
150150
display: inline-block;
151+
cursor: pointer;
152+
background: none;
153+
border: 0;
154+
padding: 0;
151155
transition: transform 0.3s;
152156

153157
&.expanded {

app/javascript/__tests__/dashboard.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ describe('defineCaseContactsTable', () => {
151151
expect(columns[1].searchable).toBe(false)
152152
})
153153

154-
it('renders chevron-down icon', () => {
154+
it('renders chevron-down icon as an accessible button', () => {
155155
const rendered = columns[1].render(null, 'display', {})
156156

157-
expect(rendered).toBe('<i class="fa-solid fa-chevron-down expand-toggle" style="cursor: pointer;"></i>')
157+
expect(rendered).toBe('<button type="button" class="expand-toggle" aria-expanded="false" aria-label="Expand row details"><i class="fa-solid fa-chevron-down" aria-hidden="true"></i></button>')
158158
})
159159
})
160160

app/javascript/src/dashboard.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const defineCaseContactsTable = function () {
6565
data: null,
6666
orderable: false,
6767
searchable: false,
68-
render: () => '<i class="fa-solid fa-chevron-down expand-toggle" style="cursor: pointer;"></i>'
68+
render: () => '<button type="button" class="expand-toggle" aria-expanded="false" aria-label="Expand row details"><i class="fa-solid fa-chevron-down" aria-hidden="true"></i></button>'
6969
},
7070
{ // Date column (index 2)
7171
data: 'occurred_at',
@@ -161,10 +161,10 @@ const defineCaseContactsTable = function () {
161161

162162
if (row.child.isShown()) {
163163
row.child.hide()
164-
$(this).removeClass('expanded')
164+
$(this).removeClass('expanded').attr('aria-expanded', 'false')
165165
} else {
166166
row.child(buildExpandedContent(row.data())).show()
167-
$(this).addClass('expanded')
167+
$(this).addClass('expanded').attr('aria-expanded', 'true')
168168
}
169169
})
170170
}

0 commit comments

Comments
 (0)