@@ -21,6 +21,49 @@ describe('Select.Accessibility', () => {
2121 expect ( container . querySelector ( 'input' ) ! . getAttribute ( 'aria-label' ) ) . toEqual ( 'light' ) ;
2222 } ) ;
2323
24+ // https://github.com/ant-design/ant-design/issues/52987
25+ it ( 'exposes the selected label as the value of a select-only combobox' , ( ) => {
26+ const options = [
27+ { value : 'lucy' , label : 'Lucy' } ,
28+ { value : 'zero' , label : 0 } ,
29+ ] ;
30+ const { getByRole, container, rerender } = render (
31+ < Select aria-label = "Person" value = "lucy" options = { options } /> ,
32+ ) ;
33+ const input = getByRole ( 'combobox' , { name : 'Person' } ) ;
34+ fireEvent . focus ( input ) ;
35+
36+ expect ( input ) . toHaveValue ( 'Lucy' ) ;
37+ expect ( container . querySelector ( '[aria-live="polite"]' ) ) . toBeNull ( ) ;
38+
39+ rerender ( < Select aria-label = "Person" value = "zero" options = { options } /> ) ;
40+ expect ( input ) . toHaveValue ( '0' ) ;
41+
42+ rerender ( < Select aria-label = "Person" value = { null } options = { options } /> ) ;
43+ expect ( input ) . toHaveValue ( '' ) ;
44+ } ) ;
45+
46+ it ( 'keeps the search input independent of the selected label' , ( ) => {
47+ const { getByRole } = render (
48+ < Select showSearch defaultValue = "lucy" options = { [ { value : 'lucy' , label : 'Lucy' } ] } /> ,
49+ ) ;
50+ const input = getByRole ( 'combobox' ) ;
51+ expect ( input ) . toHaveValue ( '' ) ;
52+ fireEvent . change ( input , { target : { value : 'lu' } } ) ;
53+ expect ( input ) . toHaveValue ( 'lu' ) ;
54+ } ) ;
55+
56+ it ( 'keeps the live region for a non-text selection label' , ( ) => {
57+ const { getByRole, container } = render (
58+ < Select defaultValue = "lucy" options = { [ { value : 'lucy' , label : < b > Lucy</ b > } ] } /> ,
59+ ) ;
60+ const input = getByRole ( 'combobox' ) ;
61+ fireEvent . focus ( input ) ;
62+
63+ expect ( input ) . toHaveValue ( '' ) ;
64+ expect ( container . querySelector ( '[aria-live="polite"]' ) ) . toHaveTextContent ( 'lucy' ) ;
65+ } ) ;
66+
2467 // https://github.com/ant-design/ant-design/issues/56841
2568 it ( 'spacebar opens dropdown (ARIA combobox)' , ( ) => {
2669 const { container } = render (
0 commit comments