File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -180,19 +180,19 @@ class Trait<T> implements ISpliceable<boolean>, IDisposable {
180180 }
181181}
182182
183- class SelectionTrait < T > extends Trait < T > {
183+ class FocusTrait < T > extends Trait < T > {
184184
185- constructor ( ) {
186- super ( 'selected ' ) ;
185+ constructor ( private isAriaSelected : ( index : number ) => boolean ) {
186+ super ( 'focused ' ) ;
187187 }
188188
189189 renderIndex ( index : number , container : HTMLElement ) : void {
190190 super . renderIndex ( index , container ) ;
191191
192- if ( this . contains ( index ) ) {
192+ if ( this . contains ( index ) || this . isAriaSelected ( index ) ) {
193193 container . setAttribute ( 'aria-selected' , 'true' ) ;
194194 } else {
195- container . removeAttribute ( 'aria-selected' ) ;
195+ container . setAttribute ( 'aria-selected' , 'false ') ;
196196 }
197197 }
198198}
@@ -1198,8 +1198,8 @@ export class List<T> implements ISpliceable<T>, IDisposable {
11981198 renderers : IListRenderer < any /* TODO@joao */ , any > [ ] ,
11991199 private _options : IListOptions < T > = DefaultOptions
12001200 ) {
1201- this . focus = new Trait ( 'focused ' ) ;
1202- this . selection = new SelectionTrait ( ) ;
1201+ this . selection = new Trait ( 'selected ' ) ;
1202+ this . focus = new FocusTrait ( this . selection . contains ) ;
12031203
12041204 mixin ( _options , defaultStyles , false ) ;
12051205
Original file line number Diff line number Diff line change @@ -219,12 +219,9 @@ export class ViewItem implements IViewItem {
219219 if ( this . model . hasTrait ( 'focused' ) ) {
220220 const base64Id = strings . safeBtoa ( this . model . id ) ;
221221 this . element . setAttribute ( 'id' , base64Id ) ;
222- } else {
223- this . element . removeAttribute ( 'id' ) ;
224- }
225- if ( this . model . hasTrait ( 'selected' ) ) {
226222 this . element . setAttribute ( 'aria-selected' , 'true' ) ;
227223 } else {
224+ this . element . removeAttribute ( 'id' ) ;
228225 this . element . setAttribute ( 'aria-selected' , 'false' ) ;
229226 }
230227 if ( this . model . hasChildren ( ) ) {
You can’t perform that action at this time.
0 commit comments