Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/giant-bees-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Fix an issue in useAnnouncements.tsx causing a TypeError in production. The activeItem variable may be null.
7 changes: 4 additions & 3 deletions packages/react/src/FilteredActionList/useAnnouncements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import {announce} from '@primer/live-region-element'
import {useEffect, useRef} from 'react'
import type {FilteredActionListProps} from './FilteredActionListEntry'
import type {ItemInput} from '../deprecated/ActionList/List'

// we add a delay so that it does not interrupt default screen reader announcement and queues after it
const delayMs = 500
Expand All @@ -28,10 +29,10 @@ const getItemWithActiveDescendant = (
const optionElements = listElement.querySelectorAll('[role="option"]')

const index = Array.from(optionElements).indexOf(activeItemElement)
const activeItem = items[index]
const activeItem = items[index] as ItemInput | undefined

const text = activeItem.text
const selected = activeItem.selected
const text = activeItem?.text
const selected = activeItem?.selected

return {index, text, selected}
}
Expand Down
Loading