1
- import { useId } from '../hooks/useId '
1
+ import { SearchIcon } from '@primer/octicons-react '
2
2
import React , { useCallback , useMemo } from 'react'
3
3
import { AnchoredOverlay , AnchoredOverlayProps } from '../AnchoredOverlay'
4
4
import { AnchoredOverlayWrapperAnchorProps } from '../AnchoredOverlay/AnchoredOverlay'
5
+ import Box from '../Box'
5
6
import { FilteredActionList , FilteredActionListProps } from '../FilteredActionList'
6
7
import Heading from '../Heading'
7
8
import { OverlayProps } from '../Overlay'
@@ -11,9 +12,9 @@ import {ItemInput} from '../deprecated/ActionList/List'
11
12
import { DropdownButton } from '../deprecated/DropdownMenu'
12
13
import { useProvidedRefOrCreate } from '../hooks'
13
14
import { FocusZoneHookSettings } from '../hooks/useFocusZone'
15
+ import { useId } from '../hooks/useId'
14
16
import { useProvidedStateOrCreate } from '../hooks/useProvidedStateOrCreate'
15
- import Box from '../Box'
16
- import { SearchIcon } from '@primer/octicons-react'
17
+ import { LiveRegion , LiveRegionOutlet , Message } from '../internal/components/LiveRegion'
17
18
18
19
interface SelectPanelSingleSelection {
19
20
selected : ItemInput | undefined
@@ -160,39 +161,51 @@ export function SelectPanel({
160
161
} , [ inputLabel , textInputProps ] )
161
162
162
163
return (
163
- < AnchoredOverlay
164
- renderAnchor = { renderMenuAnchor }
165
- anchorRef = { anchorRef }
166
- open = { open }
167
- onOpen = { onOpen }
168
- onClose = { onClose }
169
- overlayProps = { { role : 'dialog' , 'aria-labelledby' : titleId , ...overlayProps } }
170
- focusTrapSettings = { focusTrapSettings }
171
- focusZoneSettings = { focusZoneSettings }
172
- >
173
- < Box sx = { { display : 'flex' , flexDirection : 'column' , height : 'inherit' , maxHeight : 'inherit' } } >
174
- < Box sx = { { pt : 2 , px : 3 } } >
175
- < Heading as = "h1" id = { titleId } sx = { { fontSize : 1 } } >
176
- { title }
177
- </ Heading >
178
- </ Box >
179
- < FilteredActionList
180
- filterValue = { filterValue }
181
- onFilterChange = { onFilterChange }
182
- placeholderText = { placeholderText }
183
- { ...listProps }
184
- role = "listbox"
185
- aria-multiselectable = { isMultiSelectVariant ( selected ) ? 'true' : 'false' }
186
- selectionVariant = { isMultiSelectVariant ( selected ) ? 'multiple' : 'single' }
187
- items = { itemsToRender }
188
- textInputProps = { extendedTextInputProps }
189
- inputRef = { inputRef }
190
- // inheriting height and maxHeight ensures that the FilteredActionList is never taller
191
- // than the Overlay (which would break scrolling the items)
192
- sx = { { ...sx , height : 'inherit' , maxHeight : 'inherit' } }
164
+ < LiveRegion >
165
+ < AnchoredOverlay
166
+ renderAnchor = { renderMenuAnchor }
167
+ anchorRef = { anchorRef }
168
+ open = { open }
169
+ onOpen = { onOpen }
170
+ onClose = { onClose }
171
+ overlayProps = { { role : 'dialog' , 'aria-labelledby' : titleId , ...overlayProps } }
172
+ focusTrapSettings = { focusTrapSettings }
173
+ focusZoneSettings = { focusZoneSettings }
174
+ >
175
+ < LiveRegionOutlet />
176
+ < Message
177
+ value = {
178
+ filterValue === ''
179
+ ? 'Showing all items'
180
+ : items . length <= 0
181
+ ? 'No matching items'
182
+ : `${ items . length } matching ${ items . length === 1 ? 'item' : 'items' } `
183
+ }
193
184
/>
194
- </ Box >
195
- </ AnchoredOverlay >
185
+ < Box sx = { { display : 'flex' , flexDirection : 'column' , height : 'inherit' , maxHeight : 'inherit' } } >
186
+ < Box sx = { { pt : 2 , px : 3 } } >
187
+ < Heading as = "h1" id = { titleId } sx = { { fontSize : 1 } } >
188
+ { title }
189
+ </ Heading >
190
+ </ Box >
191
+ < FilteredActionList
192
+ filterValue = { filterValue }
193
+ onFilterChange = { onFilterChange }
194
+ placeholderText = { placeholderText }
195
+ { ...listProps }
196
+ role = "listbox"
197
+ aria-multiselectable = { isMultiSelectVariant ( selected ) ? 'true' : 'false' }
198
+ selectionVariant = { isMultiSelectVariant ( selected ) ? 'multiple' : 'single' }
199
+ items = { itemsToRender }
200
+ textInputProps = { extendedTextInputProps }
201
+ inputRef = { inputRef }
202
+ // inheriting height and maxHeight ensures that the FilteredActionList is never taller
203
+ // than the Overlay (which would break scrolling the items)
204
+ sx = { { ...sx , height : 'inherit' , maxHeight : 'inherit' } }
205
+ />
206
+ </ Box >
207
+ </ AnchoredOverlay >
208
+ </ LiveRegion >
196
209
)
197
210
}
198
211
0 commit comments