@@ -70,19 +70,19 @@ aria.ListboxActions = class ListboxActions {
7070 registerActionsEvents ( ) {
7171 this . listboxActionsNode . addEventListener (
7272 'keydown' ,
73- this . checkKeyPressActions . bind ( this )
73+ this . onCheckKeyPressActions . bind ( this )
7474 ) ;
7575 this . listboxActionsNode . addEventListener (
7676 'click' ,
77- this . setCurrentActiveOptionForListbox . bind ( this )
77+ this . onSetCurrentActiveOptionForListbox . bind ( this )
7878 ) ;
7979 let actionButtons = this . listboxActionsNode . querySelectorAll (
8080 'button:not(.hide-actions-button)'
8181 ) ;
8282 for ( let i = 0 ; i < actionButtons . length ; i ++ ) {
8383 actionButtons [ i ] . addEventListener (
8484 'click' ,
85- this . checkClickItemActions . bind ( this )
85+ this . onCheckClickItemActions . bind ( this )
8686 ) ;
8787 }
8888 }
@@ -110,6 +110,7 @@ aria.ListboxActions = class ListboxActions {
110110 }
111111 this . listboxActionsNode . setAttribute ( 'aria-activedescendant' , element . id ) ;
112112 this . activeDescendant = element . id ;
113+ this . listboxCurrentOptionIndex = this . listboxOptionArray . indexOf ( element ) ;
113114 }
114115 /**
115116 * @description
@@ -257,6 +258,8 @@ aria.ListboxActions = class ListboxActions {
257258 ''
258259 ) ;
259260 }
261+ this . setActiveDescendant ( this . listboxItemsWithAriaActionsArray [ 0 ] ) ;
262+ this . Listbox . focusItem ( this . listboxOptionArray [ 0 ] ) ;
260263 break ;
261264 case 'favorite' :
262265 activeButton . setAttribute (
@@ -269,8 +272,8 @@ aria.ListboxActions = class ListboxActions {
269272 activeButton . ariaPressed == 'true' ? 'favorite' : 'unfavorited' ,
270273 [ activeOption ]
271274 ) ;
272- if ( activeOption . querySelector ( '.favoriteIndication' ) ) {
273- activeOption . querySelector ( '.favoriteIndication' ) . innerText =
275+ if ( activeOption . querySelector ( '.js- favoriteIndication' ) ) {
276+ activeOption . querySelector ( '.js- favoriteIndication' ) . innerText =
274277 activeButton . ariaPressed == 'true' ? 'Favorite' : '' ;
275278 }
276279 break ;
@@ -285,20 +288,24 @@ aria.ListboxActions = class ListboxActions {
285288 }
286289 this . Listbox . updateScroll ( ) ;
287290 }
288- checkKeyPressActions ( event ) {
291+ onCheckKeyPressActions ( event ) {
289292 let listitemCurrentItemActionsButtonPosition ,
290293 listboxCurrentItemActionsButton ;
291294 this . listboxItemCurrent = this . listboxActionsNode . querySelector ( '.focused' ) ;
295+ this . listboxCurrentOptionIndex = this . listboxOptionArray . indexOf ( this . listboxItemCurrent ) ;
296+ console . log ( this . listboxCurrentOptionIndex ) ;
292297 this . activeDescendant = this . listboxActionsNode . getAttribute (
293298 'aria-activedescendant'
294299 ) ;
295300 this . listboxActiveOption =
296301 this . listboxActionsNode . querySelector ( '.focused' ) ;
297- this . listboxCurrentItemActionsButtons = Array . from (
298- this . listboxItemCurrent . querySelectorAll (
299- 'button:not(.hide-actions-button)'
300- )
301- ) ;
302+ if ( this . listboxItemCurrent ) {
303+ this . listboxCurrentItemActionsButtons = Array . from (
304+ this . listboxItemCurrent . querySelectorAll (
305+ 'button:not(.hide-actions-button)'
306+ )
307+ ) ;
308+ }
302309 this . listboxItemsWithAriaActionsArray =
303310 event . currentTarget . querySelectorAll ( '[aria-actions]' ) ;
304311 switch ( event . key ) {
@@ -390,7 +397,7 @@ aria.ListboxActions = class ListboxActions {
390397 * @param event
391398 * The click event
392399 */
393- checkClickItemActions ( event ) {
400+ onCheckClickItemActions ( event ) {
394401 event . preventDefault ( ) ;
395402 event . key = 'Enter' ;
396403 let previousFocus = this . listboxActionsNode . querySelectorAll ( '.focused' ) ;
@@ -401,7 +408,7 @@ aria.ListboxActions = class ListboxActions {
401408 }
402409 let newFocus = event . srcElement . closest ( '[role="option"]' ) ;
403410 newFocus . classList . add ( 'focused' ) ;
404- this . checkKeyPressActions ( event ) ;
411+ this . onCheckKeyPressActions ( event ) ;
405412 }
406413 /**
407414 * @description
@@ -410,7 +417,7 @@ aria.ListboxActions = class ListboxActions {
410417 * @param event
411418 * The click event
412419 */
413- setCurrentActiveOptionForListbox ( event ) {
420+ onSetCurrentActiveOptionForListbox ( event ) {
414421 if ( event . srcElement . localName != 'button' ) {
415422 for ( let i = 0 ; i < this . listboxOptionArray . length ; i ++ ) {
416423 let listboxOptionCurrent = this . listboxOptionArray [ i ] ;
0 commit comments