Skip to content

Commit c54ffe5

Browse files
committed
fix(ui): announce background activity on resource tabs
1 parent ffeea3a commit c54ffe5

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

‎packages/emcn/src/components/tab-strip/tab-strip.dom.test.tsx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,13 @@ describe('TabStrip interactions', () => {
131131
mount(renderStrip(items, vi.fn(), onClose))
132132

133133
const slot = stripItem('two').querySelector('[data-row-actions]')
134-
expect(slot?.querySelector('[aria-label="Background activity"]')).not.toBeNull()
134+
expect(slot?.querySelector('[data-row-action-indicator]')).not.toBeNull()
135+
expect(tabButton('two').getAttribute('aria-label')).toBe('Two, Background activity')
135136
const close = slot?.querySelector<HTMLButtonElement>('[aria-label="Close Two"]')
136137
expect(close).not.toBeNull()
137-
expect(tabButton('two').querySelector('[aria-label="Background activity"]')).toBeNull()
138-
expect(stripItem('one').querySelector('[aria-label="Background activity"]')).toBeNull()
139-
expect(tabButton('pinned').querySelector('[aria-label="Background activity"]')).not.toBeNull()
138+
expect(tabButton('two').querySelector('[data-row-actions]')).toBeNull()
139+
expect(tabButton('one').hasAttribute('aria-label')).toBe(false)
140+
expect(tabButton('pinned').getAttribute('aria-label')).toBe('Pinned, Background activity')
140141
act(() => close?.click())
141142
expect(onClose).toHaveBeenCalledWith('two')
142143
})
@@ -474,9 +475,10 @@ describe('TabStrip interactions', () => {
474475
it('shows background activity without marking that tab selected', () => {
475476
mount(renderStrip(tabs.map((tab) => ({ ...tab, attention: tab.id === 'two' }))))
476477

477-
expect(stripItem('two').querySelector('[aria-label="Background activity"]')).not.toBeNull()
478+
expect(stripItem('two').querySelector('[data-row-action-indicator]')).not.toBeNull()
479+
expect(tabButton('two').getAttribute('aria-label')).toBe('Two, Background activity')
478480
expect(tabButton('two').getAttribute('aria-selected')).toBe('false')
479-
expect(tabButton('one').querySelector('[aria-label="Background activity"]')).toBeNull()
481+
expect(tabButton('one').hasAttribute('aria-label')).toBe(false)
480482
})
481483

482484
it('does not reserve phantom space after a pointer close', () => {

‎packages/emcn/src/components/tab-strip/tab-strip.tsx‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,13 @@ const Tab = forwardRef<HTMLDivElement, TabProps>(function Tab(
370370
role='tab'
371371
aria-selected={Boolean(tab.active)}
372372
aria-keyshortcuts={closeable ? 'Delete' : undefined}
373-
aria-label={tab.pinned ? tab.title : undefined}
373+
aria-label={
374+
tab.attention && !tab.active
375+
? `${tab.title}, Background activity`
376+
: tab.pinned
377+
? tab.title
378+
: undefined
379+
}
374380
data-tab-strip-button={tab.id}
375381
tabIndex={focusable ? 0 : -1}
376382
className={cn(
@@ -411,7 +417,7 @@ const Tab = forwardRef<HTMLDivElement, TabProps>(function Tab(
411417
'size-1.5 shrink-0 rounded-full bg-[var(--brand-blue)]',
412418
tab.pinned && 'absolute right-1 bottom-1'
413419
)}
414-
aria-label='Background activity'
420+
aria-hidden='true'
415421
/>
416422
)}
417423
</Button>
@@ -466,10 +472,7 @@ const Tab = forwardRef<HTMLDivElement, TabProps>(function Tab(
466472
open={tab.active}
467473
indicator={
468474
tab.attention && !tab.active ? (
469-
<span
470-
className='size-1.5 rounded-full bg-[var(--brand-blue)]'
471-
aria-label='Background activity'
472-
/>
475+
<span className='size-1.5 rounded-full bg-[var(--brand-blue)]' aria-hidden='true' />
473476
) : undefined
474477
}
475478
className='-translate-y-1/2 absolute top-1/2 right-0.5 z-20'

0 commit comments

Comments
 (0)