@instructure/ui-select 11.7.4-snapshot-105 → 11.7.4-snapshot-107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/package.json +19 -19
- package/src/Select/v1/README.md +8 -81
- package/src/Select/v2/README.md +8 -81
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [11.7.4-snapshot-
|
|
6
|
+
## [11.7.4-snapshot-107](https://github.com/instructure/instructure-ui/compare/v11.7.3...v11.7.4-snapshot-107) (2026-07-16)
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-select",
|
|
3
|
-
"version": "11.7.4-snapshot-
|
|
3
|
+
"version": "11.7.4-snapshot-107",
|
|
4
4
|
"description": "A component for select and autocomplete behavior.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -15,30 +15,30 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.29.7",
|
|
18
|
-
"@instructure/emotion": "11.7.4-snapshot-
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/ui-
|
|
23
|
-
"@instructure/ui-options": "11.7.4-snapshot-
|
|
24
|
-
"@instructure/ui-popover": "11.7.4-snapshot-
|
|
25
|
-
"@instructure/ui-position": "11.7.4-snapshot-
|
|
26
|
-
"@instructure/ui-selectable": "11.7.4-snapshot-
|
|
27
|
-
"@instructure/ui-text-input": "11.7.4-snapshot-
|
|
28
|
-
"@instructure/ui-themes": "11.7.4-snapshot-
|
|
29
|
-
"@instructure/ui-utils": "11.7.4-snapshot-
|
|
30
|
-
"@instructure/
|
|
31
|
-
"@instructure/
|
|
32
|
-
"@instructure/ui-
|
|
18
|
+
"@instructure/emotion": "11.7.4-snapshot-107",
|
|
19
|
+
"@instructure/ui-icons": "11.7.4-snapshot-107",
|
|
20
|
+
"@instructure/shared-types": "11.7.4-snapshot-107",
|
|
21
|
+
"@instructure/ui-form-field": "11.7.4-snapshot-107",
|
|
22
|
+
"@instructure/ui-dom-utils": "11.7.4-snapshot-107",
|
|
23
|
+
"@instructure/ui-options": "11.7.4-snapshot-107",
|
|
24
|
+
"@instructure/ui-popover": "11.7.4-snapshot-107",
|
|
25
|
+
"@instructure/ui-position": "11.7.4-snapshot-107",
|
|
26
|
+
"@instructure/ui-selectable": "11.7.4-snapshot-107",
|
|
27
|
+
"@instructure/ui-text-input": "11.7.4-snapshot-107",
|
|
28
|
+
"@instructure/ui-themes": "11.7.4-snapshot-107",
|
|
29
|
+
"@instructure/ui-react-utils": "11.7.4-snapshot-107",
|
|
30
|
+
"@instructure/ui-utils": "11.7.4-snapshot-107",
|
|
31
|
+
"@instructure/uid": "11.7.4-snapshot-107",
|
|
32
|
+
"@instructure/ui-view": "11.7.4-snapshot-107"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@testing-library/jest-dom": "^6.9.1",
|
|
36
36
|
"@testing-library/react": "16.3.2",
|
|
37
37
|
"@testing-library/user-event": "^14.6.1",
|
|
38
38
|
"vitest": "^4.1.9",
|
|
39
|
-
"@instructure/ui-
|
|
40
|
-
"@instructure/ui-
|
|
41
|
-
"@instructure/ui-
|
|
39
|
+
"@instructure/ui-color-utils": "11.7.4-snapshot-107",
|
|
40
|
+
"@instructure/ui-scripts": "11.7.4-snapshot-107",
|
|
41
|
+
"@instructure/ui-babel-preset": "11.7.4-snapshot-107"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=18 <=19"
|
package/src/Select/v1/README.md
CHANGED
|
@@ -26,7 +26,6 @@ type: example
|
|
|
26
26
|
const [isShowingOptions, setIsShowingOptions] = useState(false)
|
|
27
27
|
const [highlightedOptionId, setHighlightedOptionId] = useState(null)
|
|
28
28
|
const [selectedOptionId, setSelectedOptionId] = useState(options[0].id)
|
|
29
|
-
const [announcement, setAnnouncement] = useState(null)
|
|
30
29
|
const inputRef = useRef()
|
|
31
30
|
|
|
32
31
|
const focusInput = () => {
|
|
@@ -61,7 +60,6 @@ type: example
|
|
|
61
60
|
setIsShowingOptions(false)
|
|
62
61
|
setHighlightedOptionId(null)
|
|
63
62
|
setSelectedOptionId(selectedOptionId ? option : '')
|
|
64
|
-
setAnnouncement('List collapsed.')
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
const handleBlur = (event) => {
|
|
@@ -70,14 +68,8 @@ type: example
|
|
|
70
68
|
|
|
71
69
|
const handleHighlightOption = (event, { id }) => {
|
|
72
70
|
event.persist()
|
|
73
|
-
const optionsAvailable = `${options.length} options available.`
|
|
74
|
-
const nowOpen = !isShowingOptions
|
|
75
|
-
? `List expanded. ${optionsAvailable}`
|
|
76
|
-
: ''
|
|
77
|
-
const option = getOptionById(id)?.label
|
|
78
71
|
setHighlightedOptionId(id)
|
|
79
72
|
setInputValue(inputValue)
|
|
80
|
-
setAnnouncement(`${option} ${nowOpen}`)
|
|
81
73
|
}
|
|
82
74
|
|
|
83
75
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -86,7 +78,6 @@ type: example
|
|
|
86
78
|
setSelectedOptionId(id)
|
|
87
79
|
setInputValue(option)
|
|
88
80
|
setIsShowingOptions(false)
|
|
89
|
-
setAnnouncement(`"${option}" selected. List collapsed.`)
|
|
90
81
|
}
|
|
91
82
|
|
|
92
83
|
return (
|
|
@@ -177,22 +168,6 @@ type: example
|
|
|
177
168
|
return options.find(({ id }) => id === queryId)
|
|
178
169
|
}
|
|
179
170
|
|
|
180
|
-
const getOptionsChangedMessage = (newOptions) => {
|
|
181
|
-
let message =
|
|
182
|
-
newOptions.length !== filteredOptions.length
|
|
183
|
-
? `${newOptions.length} options available.` // options changed, announce new total
|
|
184
|
-
: null // options haven't changed, don't announce
|
|
185
|
-
if (message && newOptions.length > 0) {
|
|
186
|
-
// options still available
|
|
187
|
-
if (highlightedOptionId !== newOptions[0].id) {
|
|
188
|
-
// highlighted option hasn't been announced
|
|
189
|
-
const option = getOptionById(newOptions[0].id).label
|
|
190
|
-
message = `${option}. ${message}`
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return message
|
|
194
|
-
}
|
|
195
|
-
|
|
196
171
|
const filterOptions = (value) => {
|
|
197
172
|
return options.filter((option) =>
|
|
198
173
|
option.label.toLowerCase().startsWith(value.toLowerCase())
|
|
@@ -231,9 +206,6 @@ type: example
|
|
|
231
206
|
|
|
232
207
|
const handleShowOptions = (event) => {
|
|
233
208
|
setIsShowingOptions(true)
|
|
234
|
-
setAnnouncement(
|
|
235
|
-
`List expanded. ${filteredOptions.length} options available.`
|
|
236
|
-
)
|
|
237
209
|
if (inputValue || selectedOptionId || options.length === 0) return
|
|
238
210
|
|
|
239
211
|
if ('key' in event) {
|
|
@@ -251,7 +223,6 @@ type: example
|
|
|
251
223
|
const handleHideOptions = (event) => {
|
|
252
224
|
setIsShowingOptions(false)
|
|
253
225
|
setHighlightedOptionId(false)
|
|
254
|
-
setAnnouncement('List collapsed.')
|
|
255
226
|
matchValue()
|
|
256
227
|
}
|
|
257
228
|
|
|
@@ -265,7 +236,6 @@ type: example
|
|
|
265
236
|
if (!option) return // prevent highlighting of empty option
|
|
266
237
|
setHighlightedOptionId(id)
|
|
267
238
|
setInputValue(inputValue)
|
|
268
|
-
setAnnouncement(option.label)
|
|
269
239
|
}
|
|
270
240
|
|
|
271
241
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -276,7 +246,6 @@ type: example
|
|
|
276
246
|
setInputValue(option.label)
|
|
277
247
|
setIsShowingOptions(false)
|
|
278
248
|
setFilteredOptions(options)
|
|
279
|
-
setAnnouncement(`${option.label} selected. List collapsed.`)
|
|
280
249
|
}
|
|
281
250
|
|
|
282
251
|
const handleInputChange = (event) => {
|
|
@@ -287,7 +256,7 @@ type: example
|
|
|
287
256
|
setHighlightedOptionId(newOptions.length > 0 ? newOptions[0].id : null)
|
|
288
257
|
setIsShowingOptions(true)
|
|
289
258
|
setSelectedOptionId(value === '' ? null : selectedOptionId)
|
|
290
|
-
setAnnouncement(
|
|
259
|
+
setAnnouncement(`${newOptions.length} options available.`)
|
|
291
260
|
}
|
|
292
261
|
|
|
293
262
|
return (
|
|
@@ -335,6 +304,13 @@ type: example
|
|
|
335
304
|
</Select.Option>
|
|
336
305
|
)}
|
|
337
306
|
</Select>
|
|
307
|
+
<Alert
|
|
308
|
+
liveRegion={() => document.getElementById('flash-messages')}
|
|
309
|
+
liveRegionPoliteness="assertive"
|
|
310
|
+
screenReaderOnly
|
|
311
|
+
>
|
|
312
|
+
{announcement}
|
|
313
|
+
</Alert>
|
|
338
314
|
</div>
|
|
339
315
|
)
|
|
340
316
|
}
|
|
@@ -378,7 +354,6 @@ type: example
|
|
|
378
354
|
const [highlightedOptionId, setHighlightedOptionId] = useState(null)
|
|
379
355
|
const [selectedOptionId, setSelectedOptionId] = useState(['opt1', 'opt6'])
|
|
380
356
|
const [filteredOptions, setFilteredOptions] = useState(options)
|
|
381
|
-
const [announcement, setAnnouncement] = useState(null)
|
|
382
357
|
const inputRef = useRef()
|
|
383
358
|
|
|
384
359
|
const focusInput = () => {
|
|
@@ -392,22 +367,6 @@ type: example
|
|
|
392
367
|
return options.find(({ id }) => id === queryId)
|
|
393
368
|
}
|
|
394
369
|
|
|
395
|
-
const getOptionsChangedMessage = (newOptions) => {
|
|
396
|
-
let message =
|
|
397
|
-
newOptions.length !== filteredOptions.length
|
|
398
|
-
? `${newOptions.length} options available.` // options changed, announce new total
|
|
399
|
-
: null // options haven't changed, don't announce
|
|
400
|
-
if (message && newOptions.length > 0) {
|
|
401
|
-
// options still available
|
|
402
|
-
if (highlightedOptionId !== newOptions[0].id) {
|
|
403
|
-
// highlighted option hasn't been announced
|
|
404
|
-
const option = getOptionById(newOptions[0].id).label
|
|
405
|
-
message = `${option}. ${message}`
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return message
|
|
409
|
-
}
|
|
410
|
-
|
|
411
370
|
const filterOptions = (value) => {
|
|
412
371
|
return options.filter((option) =>
|
|
413
372
|
option.label.toLowerCase().startsWith(value.toLowerCase())
|
|
@@ -475,7 +434,6 @@ type: example
|
|
|
475
434
|
if (!option) return // prevent highlighting empty option
|
|
476
435
|
setHighlightedOptionId(id)
|
|
477
436
|
setInputValue(inputValue)
|
|
478
|
-
setAnnouncement(option.label)
|
|
479
437
|
}
|
|
480
438
|
|
|
481
439
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -487,7 +445,6 @@ type: example
|
|
|
487
445
|
setFilteredOptions(filterOptions(''))
|
|
488
446
|
setInputValue('')
|
|
489
447
|
setIsShowingOptions(false)
|
|
490
|
-
setAnnouncement(`${option.label} selected. List collapsed.`)
|
|
491
448
|
}
|
|
492
449
|
|
|
493
450
|
const handleInputChange = (event) => {
|
|
@@ -497,7 +454,6 @@ type: example
|
|
|
497
454
|
setFilteredOptions(newOptions)
|
|
498
455
|
setHighlightedOptionId(newOptions.length > 0 ? newOptions[0].id : null)
|
|
499
456
|
setIsShowingOptions(true)
|
|
500
|
-
setAnnouncement(getOptionsChangedMessage(newOptions))
|
|
501
457
|
}
|
|
502
458
|
|
|
503
459
|
const handleKeyDown = (event) => {
|
|
@@ -521,7 +477,6 @@ type: example
|
|
|
521
477
|
|
|
522
478
|
setSelectedOptionId(newSelection)
|
|
523
479
|
setHighlightedOptionId(null)
|
|
524
|
-
setAnnouncement(`${getOptionById(tag).label} removed`)
|
|
525
480
|
|
|
526
481
|
inputRef.current.focus()
|
|
527
482
|
}
|
|
@@ -628,7 +583,6 @@ const GroupSelectExample = ({ options }) => {
|
|
|
628
583
|
const [selectedOptionId, setSelectedOptionId] = useState(
|
|
629
584
|
options['Western'][0].id
|
|
630
585
|
)
|
|
631
|
-
const [announcement, setAnnouncement] = useState(null)
|
|
632
586
|
const inputRef = useRef()
|
|
633
587
|
|
|
634
588
|
const focusInput = () => {
|
|
@@ -654,15 +608,6 @@ const GroupSelectExample = ({ options }) => {
|
|
|
654
608
|
return match
|
|
655
609
|
}
|
|
656
610
|
|
|
657
|
-
const getGroupChangedMessage = (newOption) => {
|
|
658
|
-
const currentOption = getOptionById(highlightedOptionId)
|
|
659
|
-
const isNewGroup =
|
|
660
|
-
!currentOption || currentOption.group !== newOption.group
|
|
661
|
-
let message = isNewGroup ? `Group ${newOption.group} entered. ` : ''
|
|
662
|
-
message += newOption.label
|
|
663
|
-
return message
|
|
664
|
-
}
|
|
665
|
-
|
|
666
611
|
const handleShowOptions = (event) => {
|
|
667
612
|
setIsShowingOptions(true)
|
|
668
613
|
setHighlightedOptionId(null)
|
|
@@ -694,10 +639,8 @@ const GroupSelectExample = ({ options }) => {
|
|
|
694
639
|
|
|
695
640
|
const handleHighlightOption = (event, { id }) => {
|
|
696
641
|
event.persist()
|
|
697
|
-
const newOption = getOptionById(id)
|
|
698
642
|
setHighlightedOptionId(id)
|
|
699
643
|
setInputValue(inputValue)
|
|
700
|
-
setAnnouncement(getGroupChangedMessage(newOption))
|
|
701
644
|
}
|
|
702
645
|
|
|
703
646
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -705,7 +648,6 @@ const GroupSelectExample = ({ options }) => {
|
|
|
705
648
|
setSelectedOptionId(id)
|
|
706
649
|
setInputValue(getOptionById(id).label)
|
|
707
650
|
setIsShowingOptions(false)
|
|
708
|
-
setAnnouncement(`${getOptionById(id).label} selected.`)
|
|
709
651
|
}
|
|
710
652
|
|
|
711
653
|
const renderLabel = (text, variant) => {
|
|
@@ -997,7 +939,6 @@ const AsyncExample = ({ options }) => {
|
|
|
997
939
|
const [selectedOptionId, setSelectedOptionId] = useState(null)
|
|
998
940
|
const [selectedOptionLabel, setSelectedOptionLabel] = useState('')
|
|
999
941
|
const [filteredOptions, setFilteredOptions] = useState([])
|
|
1000
|
-
const [announcement, setAnnouncement] = useState(null)
|
|
1001
942
|
const inputRef = useRef()
|
|
1002
943
|
|
|
1003
944
|
const focusInput = () => {
|
|
@@ -1050,7 +991,6 @@ const AsyncExample = ({ options }) => {
|
|
|
1050
991
|
const handleHideOptions = (event) => {
|
|
1051
992
|
setIsShowingOptions(false)
|
|
1052
993
|
setHighlightedOptionId(null)
|
|
1053
|
-
setAnnouncement('List collapsed.')
|
|
1054
994
|
matchValue()
|
|
1055
995
|
}
|
|
1056
996
|
|
|
@@ -1065,7 +1005,6 @@ const AsyncExample = ({ options }) => {
|
|
|
1065
1005
|
|
|
1066
1006
|
setHighlightedOptionId(id)
|
|
1067
1007
|
setInputValue(inputValue)
|
|
1068
|
-
setAnnouncement(option.label)
|
|
1069
1008
|
}
|
|
1070
1009
|
|
|
1071
1010
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -1076,7 +1015,6 @@ const AsyncExample = ({ options }) => {
|
|
|
1076
1015
|
setSelectedOptionLabel(option.label)
|
|
1077
1016
|
setInputValue(option.label)
|
|
1078
1017
|
setIsShowingOptions(false)
|
|
1079
|
-
setAnnouncement(`${option.label} selected. List collapsed.`)
|
|
1080
1018
|
setFilteredOptions([getOptionById(id)])
|
|
1081
1019
|
}
|
|
1082
1020
|
|
|
@@ -1097,13 +1035,11 @@ const AsyncExample = ({ options }) => {
|
|
|
1097
1035
|
setIsShowingOptions(true)
|
|
1098
1036
|
setFilteredOptions([])
|
|
1099
1037
|
setHighlightedOptionId(null)
|
|
1100
|
-
setAnnouncement('Loading options.')
|
|
1101
1038
|
|
|
1102
1039
|
timeoutId = setTimeout(() => {
|
|
1103
1040
|
const newOptions = filterOptions(value)
|
|
1104
1041
|
setFilteredOptions(newOptions)
|
|
1105
1042
|
setIsLoading(false)
|
|
1106
|
-
setAnnouncement(`${newOptions.length} options available.`)
|
|
1107
1043
|
}, 1500)
|
|
1108
1044
|
}
|
|
1109
1045
|
}
|
|
@@ -1196,7 +1132,6 @@ const SingleSelectExample = ({ options }) => {
|
|
|
1196
1132
|
const [isShowingOptions, setIsShowingOptions] = useState(false)
|
|
1197
1133
|
const [highlightedOptionId, setHighlightedOptionId] = useState(null)
|
|
1198
1134
|
const [selectedOptionId, setSelectedOptionId] = useState(options[0].id)
|
|
1199
|
-
const [announcement, setAnnouncement] = useState(null)
|
|
1200
1135
|
const inputRef = useRef()
|
|
1201
1136
|
|
|
1202
1137
|
const focusInput = () => {
|
|
@@ -1232,7 +1167,6 @@ const SingleSelectExample = ({ options }) => {
|
|
|
1232
1167
|
setIsShowingOptions(false)
|
|
1233
1168
|
setHighlightedOptionId(null)
|
|
1234
1169
|
setInputValue(selectedOptionId ? option : '')
|
|
1235
|
-
setAnnouncement('List collapsed.')
|
|
1236
1170
|
}
|
|
1237
1171
|
|
|
1238
1172
|
const handleBlur = (event) => {
|
|
@@ -1241,14 +1175,8 @@ const SingleSelectExample = ({ options }) => {
|
|
|
1241
1175
|
|
|
1242
1176
|
const handleHighlightOption = (event, { id }) => {
|
|
1243
1177
|
event.persist()
|
|
1244
|
-
const optionsAvailable = `${options.length} options available.`
|
|
1245
|
-
const nowOpen = !isShowingOptions
|
|
1246
|
-
? `List expanded. ${optionsAvailable}`
|
|
1247
|
-
: ''
|
|
1248
|
-
const option = getOptionById(id).label
|
|
1249
1178
|
setHighlightedOptionId(id)
|
|
1250
1179
|
setInputValue(inputValue)
|
|
1251
|
-
setAnnouncement(`${option} ${nowOpen}`)
|
|
1252
1180
|
}
|
|
1253
1181
|
|
|
1254
1182
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -1257,7 +1185,6 @@ const SingleSelectExample = ({ options }) => {
|
|
|
1257
1185
|
setSelectedOptionId(id)
|
|
1258
1186
|
setInputValue(option)
|
|
1259
1187
|
setIsShowingOptions(false)
|
|
1260
|
-
setAnnouncement(`"${option}" selected. List collapsed.`)
|
|
1261
1188
|
}
|
|
1262
1189
|
|
|
1263
1190
|
return (
|
package/src/Select/v2/README.md
CHANGED
|
@@ -26,7 +26,6 @@ type: example
|
|
|
26
26
|
const [isShowingOptions, setIsShowingOptions] = useState(false)
|
|
27
27
|
const [highlightedOptionId, setHighlightedOptionId] = useState(null)
|
|
28
28
|
const [selectedOptionId, setSelectedOptionId] = useState(options[0].id)
|
|
29
|
-
const [announcement, setAnnouncement] = useState(null)
|
|
30
29
|
const inputRef = useRef()
|
|
31
30
|
|
|
32
31
|
const focusInput = () => {
|
|
@@ -61,7 +60,6 @@ type: example
|
|
|
61
60
|
setIsShowingOptions(false)
|
|
62
61
|
setHighlightedOptionId(null)
|
|
63
62
|
setSelectedOptionId(selectedOptionId ? option : '')
|
|
64
|
-
setAnnouncement('List collapsed.')
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
const handleBlur = (event) => {
|
|
@@ -70,14 +68,8 @@ type: example
|
|
|
70
68
|
|
|
71
69
|
const handleHighlightOption = (event, { id }) => {
|
|
72
70
|
event.persist()
|
|
73
|
-
const optionsAvailable = `${options.length} options available.`
|
|
74
|
-
const nowOpen = !isShowingOptions
|
|
75
|
-
? `List expanded. ${optionsAvailable}`
|
|
76
|
-
: ''
|
|
77
|
-
const option = getOptionById(id)?.label
|
|
78
71
|
setHighlightedOptionId(id)
|
|
79
72
|
setInputValue(inputValue)
|
|
80
|
-
setAnnouncement(`${option} ${nowOpen}`)
|
|
81
73
|
}
|
|
82
74
|
|
|
83
75
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -86,7 +78,6 @@ type: example
|
|
|
86
78
|
setSelectedOptionId(id)
|
|
87
79
|
setInputValue(option)
|
|
88
80
|
setIsShowingOptions(false)
|
|
89
|
-
setAnnouncement(`"${option}" selected. List collapsed.`)
|
|
90
81
|
}
|
|
91
82
|
|
|
92
83
|
return (
|
|
@@ -177,22 +168,6 @@ type: example
|
|
|
177
168
|
return options.find(({ id }) => id === queryId)
|
|
178
169
|
}
|
|
179
170
|
|
|
180
|
-
const getOptionsChangedMessage = (newOptions) => {
|
|
181
|
-
let message =
|
|
182
|
-
newOptions.length !== filteredOptions.length
|
|
183
|
-
? `${newOptions.length} options available.` // options changed, announce new total
|
|
184
|
-
: null // options haven't changed, don't announce
|
|
185
|
-
if (message && newOptions.length > 0) {
|
|
186
|
-
// options still available
|
|
187
|
-
if (highlightedOptionId !== newOptions[0].id) {
|
|
188
|
-
// highlighted option hasn't been announced
|
|
189
|
-
const option = getOptionById(newOptions[0].id).label
|
|
190
|
-
message = `${option}. ${message}`
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return message
|
|
194
|
-
}
|
|
195
|
-
|
|
196
171
|
const filterOptions = (value) => {
|
|
197
172
|
return options.filter((option) =>
|
|
198
173
|
option.label.toLowerCase().startsWith(value.toLowerCase())
|
|
@@ -231,9 +206,6 @@ type: example
|
|
|
231
206
|
|
|
232
207
|
const handleShowOptions = (event) => {
|
|
233
208
|
setIsShowingOptions(true)
|
|
234
|
-
setAnnouncement(
|
|
235
|
-
`List expanded. ${filteredOptions.length} options available.`
|
|
236
|
-
)
|
|
237
209
|
if (inputValue || selectedOptionId || options.length === 0) return
|
|
238
210
|
|
|
239
211
|
if ('key' in event) {
|
|
@@ -251,7 +223,6 @@ type: example
|
|
|
251
223
|
const handleHideOptions = (event) => {
|
|
252
224
|
setIsShowingOptions(false)
|
|
253
225
|
setHighlightedOptionId(false)
|
|
254
|
-
setAnnouncement('List collapsed.')
|
|
255
226
|
matchValue()
|
|
256
227
|
}
|
|
257
228
|
|
|
@@ -265,7 +236,6 @@ type: example
|
|
|
265
236
|
if (!option) return // prevent highlighting of empty option
|
|
266
237
|
setHighlightedOptionId(id)
|
|
267
238
|
setInputValue(inputValue)
|
|
268
|
-
setAnnouncement(option.label)
|
|
269
239
|
}
|
|
270
240
|
|
|
271
241
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -276,7 +246,6 @@ type: example
|
|
|
276
246
|
setInputValue(option.label)
|
|
277
247
|
setIsShowingOptions(false)
|
|
278
248
|
setFilteredOptions(options)
|
|
279
|
-
setAnnouncement(`${option.label} selected. List collapsed.`)
|
|
280
249
|
}
|
|
281
250
|
|
|
282
251
|
const handleInputChange = (event) => {
|
|
@@ -287,7 +256,7 @@ type: example
|
|
|
287
256
|
setHighlightedOptionId(newOptions.length > 0 ? newOptions[0].id : null)
|
|
288
257
|
setIsShowingOptions(true)
|
|
289
258
|
setSelectedOptionId(value === '' ? null : selectedOptionId)
|
|
290
|
-
setAnnouncement(
|
|
259
|
+
setAnnouncement(`${newOptions.length} options available.`)
|
|
291
260
|
}
|
|
292
261
|
|
|
293
262
|
return (
|
|
@@ -333,6 +302,13 @@ type: example
|
|
|
333
302
|
</Select.Option>
|
|
334
303
|
)}
|
|
335
304
|
</Select>
|
|
305
|
+
<Alert
|
|
306
|
+
liveRegion={() => document.getElementById('flash-messages')}
|
|
307
|
+
liveRegionPoliteness="assertive"
|
|
308
|
+
screenReaderOnly
|
|
309
|
+
>
|
|
310
|
+
{announcement}
|
|
311
|
+
</Alert>
|
|
336
312
|
</div>
|
|
337
313
|
)
|
|
338
314
|
}
|
|
@@ -376,7 +352,6 @@ type: example
|
|
|
376
352
|
const [highlightedOptionId, setHighlightedOptionId] = useState(null)
|
|
377
353
|
const [selectedOptionId, setSelectedOptionId] = useState(['opt1', 'opt6'])
|
|
378
354
|
const [filteredOptions, setFilteredOptions] = useState(options)
|
|
379
|
-
const [announcement, setAnnouncement] = useState(null)
|
|
380
355
|
const inputRef = useRef()
|
|
381
356
|
|
|
382
357
|
const focusInput = () => {
|
|
@@ -390,22 +365,6 @@ type: example
|
|
|
390
365
|
return options.find(({ id }) => id === queryId)
|
|
391
366
|
}
|
|
392
367
|
|
|
393
|
-
const getOptionsChangedMessage = (newOptions) => {
|
|
394
|
-
let message =
|
|
395
|
-
newOptions.length !== filteredOptions.length
|
|
396
|
-
? `${newOptions.length} options available.` // options changed, announce new total
|
|
397
|
-
: null // options haven't changed, don't announce
|
|
398
|
-
if (message && newOptions.length > 0) {
|
|
399
|
-
// options still available
|
|
400
|
-
if (highlightedOptionId !== newOptions[0].id) {
|
|
401
|
-
// highlighted option hasn't been announced
|
|
402
|
-
const option = getOptionById(newOptions[0].id).label
|
|
403
|
-
message = `${option}. ${message}`
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
return message
|
|
407
|
-
}
|
|
408
|
-
|
|
409
368
|
const filterOptions = (value) => {
|
|
410
369
|
return options.filter((option) =>
|
|
411
370
|
option.label.toLowerCase().startsWith(value.toLowerCase())
|
|
@@ -473,7 +432,6 @@ type: example
|
|
|
473
432
|
if (!option) return // prevent highlighting empty option
|
|
474
433
|
setHighlightedOptionId(id)
|
|
475
434
|
setInputValue(inputValue)
|
|
476
|
-
setAnnouncement(option.label)
|
|
477
435
|
}
|
|
478
436
|
|
|
479
437
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -485,7 +443,6 @@ type: example
|
|
|
485
443
|
setFilteredOptions(filterOptions(''))
|
|
486
444
|
setInputValue('')
|
|
487
445
|
setIsShowingOptions(false)
|
|
488
|
-
setAnnouncement(`${option.label} selected. List collapsed.`)
|
|
489
446
|
}
|
|
490
447
|
|
|
491
448
|
const handleInputChange = (event) => {
|
|
@@ -495,7 +452,6 @@ type: example
|
|
|
495
452
|
setFilteredOptions(newOptions)
|
|
496
453
|
setHighlightedOptionId(newOptions.length > 0 ? newOptions[0].id : null)
|
|
497
454
|
setIsShowingOptions(true)
|
|
498
|
-
setAnnouncement(getOptionsChangedMessage(newOptions))
|
|
499
455
|
}
|
|
500
456
|
|
|
501
457
|
const handleKeyDown = (event) => {
|
|
@@ -519,7 +475,6 @@ type: example
|
|
|
519
475
|
|
|
520
476
|
setSelectedOptionId(newSelection)
|
|
521
477
|
setHighlightedOptionId(null)
|
|
522
|
-
setAnnouncement(`${getOptionById(tag).label} removed`)
|
|
523
478
|
|
|
524
479
|
inputRef.current.focus()
|
|
525
480
|
}
|
|
@@ -626,7 +581,6 @@ const GroupSelectExample = ({ options }) => {
|
|
|
626
581
|
const [selectedOptionId, setSelectedOptionId] = useState(
|
|
627
582
|
options['Western'][0].id
|
|
628
583
|
)
|
|
629
|
-
const [announcement, setAnnouncement] = useState(null)
|
|
630
584
|
const inputRef = useRef()
|
|
631
585
|
|
|
632
586
|
const focusInput = () => {
|
|
@@ -652,15 +606,6 @@ const GroupSelectExample = ({ options }) => {
|
|
|
652
606
|
return match
|
|
653
607
|
}
|
|
654
608
|
|
|
655
|
-
const getGroupChangedMessage = (newOption) => {
|
|
656
|
-
const currentOption = getOptionById(highlightedOptionId)
|
|
657
|
-
const isNewGroup =
|
|
658
|
-
!currentOption || currentOption.group !== newOption.group
|
|
659
|
-
let message = isNewGroup ? `Group ${newOption.group} entered. ` : ''
|
|
660
|
-
message += newOption.label
|
|
661
|
-
return message
|
|
662
|
-
}
|
|
663
|
-
|
|
664
609
|
const handleShowOptions = (event) => {
|
|
665
610
|
setIsShowingOptions(true)
|
|
666
611
|
setHighlightedOptionId(null)
|
|
@@ -692,10 +637,8 @@ const GroupSelectExample = ({ options }) => {
|
|
|
692
637
|
|
|
693
638
|
const handleHighlightOption = (event, { id }) => {
|
|
694
639
|
event.persist()
|
|
695
|
-
const newOption = getOptionById(id)
|
|
696
640
|
setHighlightedOptionId(id)
|
|
697
641
|
setInputValue(inputValue)
|
|
698
|
-
setAnnouncement(getGroupChangedMessage(newOption))
|
|
699
642
|
}
|
|
700
643
|
|
|
701
644
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -703,7 +646,6 @@ const GroupSelectExample = ({ options }) => {
|
|
|
703
646
|
setSelectedOptionId(id)
|
|
704
647
|
setInputValue(getOptionById(id).label)
|
|
705
648
|
setIsShowingOptions(false)
|
|
706
|
-
setAnnouncement(`${getOptionById(id).label} selected.`)
|
|
707
649
|
}
|
|
708
650
|
|
|
709
651
|
const renderLabel = (text, variant) => {
|
|
@@ -995,7 +937,6 @@ const AsyncExample = ({ options }) => {
|
|
|
995
937
|
const [selectedOptionId, setSelectedOptionId] = useState(null)
|
|
996
938
|
const [selectedOptionLabel, setSelectedOptionLabel] = useState('')
|
|
997
939
|
const [filteredOptions, setFilteredOptions] = useState([])
|
|
998
|
-
const [announcement, setAnnouncement] = useState(null)
|
|
999
940
|
const inputRef = useRef()
|
|
1000
941
|
|
|
1001
942
|
const focusInput = () => {
|
|
@@ -1048,7 +989,6 @@ const AsyncExample = ({ options }) => {
|
|
|
1048
989
|
const handleHideOptions = (event) => {
|
|
1049
990
|
setIsShowingOptions(false)
|
|
1050
991
|
setHighlightedOptionId(null)
|
|
1051
|
-
setAnnouncement('List collapsed.')
|
|
1052
992
|
matchValue()
|
|
1053
993
|
}
|
|
1054
994
|
|
|
@@ -1063,7 +1003,6 @@ const AsyncExample = ({ options }) => {
|
|
|
1063
1003
|
|
|
1064
1004
|
setHighlightedOptionId(id)
|
|
1065
1005
|
setInputValue(inputValue)
|
|
1066
|
-
setAnnouncement(option.label)
|
|
1067
1006
|
}
|
|
1068
1007
|
|
|
1069
1008
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -1074,7 +1013,6 @@ const AsyncExample = ({ options }) => {
|
|
|
1074
1013
|
setSelectedOptionLabel(option.label)
|
|
1075
1014
|
setInputValue(option.label)
|
|
1076
1015
|
setIsShowingOptions(false)
|
|
1077
|
-
setAnnouncement(`${option.label} selected. List collapsed.`)
|
|
1078
1016
|
setFilteredOptions([getOptionById(id)])
|
|
1079
1017
|
}
|
|
1080
1018
|
|
|
@@ -1095,13 +1033,11 @@ const AsyncExample = ({ options }) => {
|
|
|
1095
1033
|
setIsShowingOptions(true)
|
|
1096
1034
|
setFilteredOptions([])
|
|
1097
1035
|
setHighlightedOptionId(null)
|
|
1098
|
-
setAnnouncement('Loading options.')
|
|
1099
1036
|
|
|
1100
1037
|
timeoutId = setTimeout(() => {
|
|
1101
1038
|
const newOptions = filterOptions(value)
|
|
1102
1039
|
setFilteredOptions(newOptions)
|
|
1103
1040
|
setIsLoading(false)
|
|
1104
|
-
setAnnouncement(`${newOptions.length} options available.`)
|
|
1105
1041
|
}, 1500)
|
|
1106
1042
|
}
|
|
1107
1043
|
}
|
|
@@ -1192,7 +1128,6 @@ const SingleSelectExample = ({ options }) => {
|
|
|
1192
1128
|
const [isShowingOptions, setIsShowingOptions] = useState(false)
|
|
1193
1129
|
const [highlightedOptionId, setHighlightedOptionId] = useState(null)
|
|
1194
1130
|
const [selectedOptionId, setSelectedOptionId] = useState(options[0].id)
|
|
1195
|
-
const [announcement, setAnnouncement] = useState(null)
|
|
1196
1131
|
const inputRef = useRef()
|
|
1197
1132
|
|
|
1198
1133
|
const focusInput = () => {
|
|
@@ -1228,7 +1163,6 @@ const SingleSelectExample = ({ options }) => {
|
|
|
1228
1163
|
setIsShowingOptions(false)
|
|
1229
1164
|
setHighlightedOptionId(null)
|
|
1230
1165
|
setInputValue(selectedOptionId ? option : '')
|
|
1231
|
-
setAnnouncement('List collapsed.')
|
|
1232
1166
|
}
|
|
1233
1167
|
|
|
1234
1168
|
const handleBlur = (event) => {
|
|
@@ -1237,14 +1171,8 @@ const SingleSelectExample = ({ options }) => {
|
|
|
1237
1171
|
|
|
1238
1172
|
const handleHighlightOption = (event, { id }) => {
|
|
1239
1173
|
event.persist()
|
|
1240
|
-
const optionsAvailable = `${options.length} options available.`
|
|
1241
|
-
const nowOpen = !isShowingOptions
|
|
1242
|
-
? `List expanded. ${optionsAvailable}`
|
|
1243
|
-
: ''
|
|
1244
|
-
const option = getOptionById(id).label
|
|
1245
1174
|
setHighlightedOptionId(id)
|
|
1246
1175
|
setInputValue(inputValue)
|
|
1247
|
-
setAnnouncement(`${option} ${nowOpen}`)
|
|
1248
1176
|
}
|
|
1249
1177
|
|
|
1250
1178
|
const handleSelectOption = (event, { id }) => {
|
|
@@ -1253,7 +1181,6 @@ const SingleSelectExample = ({ options }) => {
|
|
|
1253
1181
|
setSelectedOptionId(id)
|
|
1254
1182
|
setInputValue(option)
|
|
1255
1183
|
setIsShowingOptions(false)
|
|
1256
|
-
setAnnouncement(`"${option}" selected. List collapsed.`)
|
|
1257
1184
|
}
|
|
1258
1185
|
|
|
1259
1186
|
return (
|