@@ -73,6 +73,19 @@ TextInput= function(parentNode, host) {
73
73
74
74
numberOfExtraLines = number ;
75
75
} ;
76
+
77
+ this . setAriaLabel = function ( ) {
78
+ var ariaLabel = "" ;
79
+ if ( host . $textInputAriaLabel ) {
80
+ ariaLabel += `${ host . $textInputAriaLabel } , ` ;
81
+ }
82
+ if ( host . session ) {
83
+ var row = host . session . selection . cursor . row ;
84
+ ariaLabel += nls ( "text-input.aria-label" , "Cursor at row $0" , [ row + 1 ] ) ;
85
+ }
86
+ text . setAttribute ( "aria-label" , ariaLabel ) ;
87
+ } ;
88
+
76
89
this . setAriaOptions = function ( options ) {
77
90
if ( options . activeDescendant ) {
78
91
text . setAttribute ( "aria-haspopup" , "true" ) ;
@@ -88,19 +101,11 @@ TextInput= function(parentNode, host) {
88
101
}
89
102
if ( options . setLabel ) {
90
103
text . setAttribute ( "aria-roledescription" , nls ( "text-input.aria-roledescription" , "editor" ) ) ;
91
- var arialLabel = "" ;
92
- if ( host . $textInputAriaLabel ) {
93
- arialLabel += `${ host . $textInputAriaLabel } , ` ;
94
- }
95
- if ( host . session ) {
96
- var row = host . session . selection . cursor . row ;
97
- arialLabel += nls ( "text-input.aria-label" , "Cursor at row $0" , [ row + 1 ] ) ;
98
- }
99
- text . setAttribute ( "aria-label" , arialLabel ) ;
104
+ this . setAriaLabel ( ) ;
100
105
}
101
106
} ;
102
107
103
- this . setAriaOptions ( { role : "textbox" } ) ;
108
+ this . setAriaOptions ( { role : "textbox" } ) ;
104
109
105
110
event . addListener ( text , "blur" , function ( e ) {
106
111
if ( ignoreFocusEvents ) return ;
@@ -191,6 +196,9 @@ TextInput= function(parentNode, host) {
191
196
// sync value of textarea
192
197
resetSelection ( ) ;
193
198
} ) ;
199
+
200
+ // if cursor changes position, we need to update the label with the correct row
201
+ host . on ( "changeSelection" , this . setAriaLabel ) ;
194
202
195
203
// Convert from row,column position to the linear position with respect to the current
196
204
// block of lines in the textarea.
0 commit comments