@@ -1235,6 +1235,25 @@ export default class Select<
1235
1235
this . setState ( { ariaSelection : { value, ...actionMeta } } ) ;
1236
1236
} ;
1237
1237
1238
+ getAriaDescribedByValue = ( ) => {
1239
+ const { ariaSelection } = this . state ;
1240
+ const ariaDescribedByIds = [ ] ;
1241
+
1242
+ if ( this . hasValue ( ) && ariaSelection ?. action === 'initial-input-focus' ) {
1243
+ ariaDescribedByIds . push ( this . getElementId ( 'live-region' ) ) ;
1244
+ }
1245
+
1246
+ if ( ! this . hasValue ( ) ) {
1247
+ ariaDescribedByIds . push ( this . getElementId ( 'placeholder' ) ) ;
1248
+ }
1249
+
1250
+ if ( this . props [ 'aria-describedby' ] != null ) {
1251
+ ariaDescribedByIds . push ( this . props [ 'aria-describedby' ] ) ;
1252
+ }
1253
+
1254
+ return ariaDescribedByIds . join ( ' ' ) ;
1255
+ } ;
1256
+
1238
1257
hasValue ( ) {
1239
1258
const { selectValue } = this . state ;
1240
1259
return selectValue . length > 0 ;
@@ -1710,7 +1729,7 @@ export default class Select<
1710
1729
required,
1711
1730
} = this . props ;
1712
1731
const { Input } = this . getComponents ( ) ;
1713
- const { inputIsHidden, ariaSelection } = this . state ;
1732
+ const { inputIsHidden } = this . state ;
1714
1733
const { commonProps } = this ;
1715
1734
1716
1735
const id = inputId || this . getElementId ( 'input' ) ;
@@ -1736,22 +1755,9 @@ export default class Select<
1736
1755
...( ! isSearchable && {
1737
1756
'aria-readonly' : true ,
1738
1757
} ) ,
1739
- ...( this . hasValue ( )
1740
- ? ariaSelection ?. action === 'initial-input-focus' && {
1741
- 'aria-describedby' : this . getElementId ( 'live-region' ) ,
1742
- }
1743
- : {
1744
- 'aria-describedby' : this . getElementId ( 'placeholder' ) ,
1745
- } ) ,
1758
+ 'aria-describedby' : this . getAriaDescribedByValue ( ) ,
1746
1759
} ;
1747
1760
1748
- // aria-describedby allows for multiple IDs to be specified, separated by a space
1749
- if ( this . props [ 'aria-describedby' ] != null ) {
1750
- ariaAttributes [
1751
- 'aria-describedby'
1752
- ] += ` ${ this . props [ 'aria-describedby' ] } ` ;
1753
- }
1754
-
1755
1761
if ( ! isSearchable ) {
1756
1762
// use a dummy input to maintain focus/blur functionality
1757
1763
return (
0 commit comments