@@ -16,7 +16,7 @@ import {KeyboardEventManager, PointerEventManager} from '../behaviors/event-mana
1616// } from '../behaviors/list-navigation/list-navigation';
1717import { SignalLike } from '../behaviors/signal-like/signal-like' ;
1818
19- import { RadioButtonPatternType , RadioButtonPattern } from '../radio-group/radio-button' ;
19+ import { RadioButtonPattern } from '../radio-group/radio-button' ;
2020
2121import { List , ListInputs , ListItem } from '../behaviors/list/list' ;
2222
@@ -59,24 +59,47 @@ export class ToolbarPattern<V> {
5959 return this . inputs . textDirection ( ) === 'rtl' ? 'ArrowLeft' : 'ArrowRight' ;
6060 } ) ;
6161
62+ /** The alternate key used to navigate to the previous widget */
63+ altPrevKey = computed ( ( ) => {
64+ if ( this . inputs . orientation ( ) === 'vertical' ) {
65+ return this . inputs . textDirection ( ) === 'rtl' ? 'ArrowRight' : 'ArrowLeft' ;
66+ }
67+ return 'ArrowUp' ;
68+ } ) ;
69+
70+ /** The alternate key used to navigate to the next widget. */
71+ altNextKey = computed ( ( ) => {
72+ if ( this . inputs . orientation ( ) === 'vertical' ) {
73+ return this . inputs . textDirection ( ) === 'rtl' ? 'ArrowLeft' : 'ArrowRight' ;
74+ }
75+ return 'ArrowDown' ;
76+ } ) ;
77+
6278 /** The keydown event manager for the toolbar. */
6379 keydown = computed ( ( ) => {
6480 const manager = new KeyboardEventManager ( ) ;
65- console . log ( ' all curent itmes' , this . inputs . items ( ) ) ;
6681
6782 return manager
6883 . on ( ' ' , ( ) => this . toolbarSelectOverride ( ) )
6984 . on ( 'Enter' , ( ) => this . toolbarSelectOverride ( ) )
7085 . on ( this . prevKey , ( ) => this . listBehavior . prev ( ) )
71- . on ( 'ArrowDown' , ( ) => {
86+ . on ( this . nextKey , ( ) => this . listBehavior . next ( ) )
87+ . on ( this . altNextKey , ( ) => {
7288 const activeItem = this . inputs . activeItem ( ) ;
7389 if ( activeItem instanceof RadioButtonPattern && activeItem . group ( ) ! ! ) {
7490 activeItem . group ( ) ?. listBehavior . next ( ) ;
7591 } else {
7692 this . listBehavior . next ( ) ;
7793 }
7894 } )
79- . on ( 'ArrowRight' , ( ) => this . listBehavior . next ( ) )
95+ . on ( this . altPrevKey , ( ) => {
96+ const activeItem = this . inputs . activeItem ( ) ;
97+ if ( activeItem instanceof RadioButtonPattern && activeItem . group ( ) ! ! ) {
98+ activeItem . group ( ) ?. listBehavior . prev ( ) ;
99+ } else {
100+ this . listBehavior . prev ( ) ;
101+ }
102+ } )
80103 . on ( 'Home' , ( ) => this . listBehavior . first ( ) )
81104 . on ( 'End' , ( ) => this . listBehavior . last ( ) ) ;
82105 } ) ;
@@ -87,10 +110,9 @@ export class ToolbarPattern<V> {
87110 /** If the active item is a Radio Button, indicate to the group the selection */
88111 if ( activeItem instanceof RadioButtonPattern ) {
89112 const group = activeItem . group ( ) ;
90- if ( group && ! group . readonly ( ) ) {
113+ if ( group && ! group . readonly ( ) && ! group . disabled ( ) ) {
91114 group . listBehavior . selectOne ( ) ;
92115 }
93- // todo fix
94116 } else {
95117 /** Item is a Toolbar Widget, manually select it */
96118 if ( activeItem && activeItem . element ( ) && ! activeItem . disabled ( ) )
@@ -112,9 +134,13 @@ export class ToolbarPattern<V> {
112134 if ( ! item ) return ;
113135
114136 if ( item instanceof RadioButtonPattern ) {
115- // have the radio group handle the selection
137+ const group = item . group ( ) ;
138+ if ( group && ! group . readonly ( ) && ! group . disabled ( ) ) {
139+ group . listBehavior . goto ( item , { selectOne : true } ) ;
140+ }
141+ } else {
142+ this . listBehavior . goto ( item ) ;
116143 }
117- this . listBehavior . goto ( item ) ;
118144 }
119145
120146 /** Handles keydown events for the toolbar. */
@@ -126,7 +152,6 @@ export class ToolbarPattern<V> {
126152
127153 /** Handles pointerdown events for the toolbar. */
128154 onPointerdown ( event : PointerEvent ) {
129- console . log ( 'this disabled' , this . disabled ( ) ) ;
130155 if ( ! this . disabled ( ) ) {
131156 this . pointerdown ( ) . handle ( event ) ;
132157 }
@@ -177,7 +202,6 @@ export class ToolbarPattern<V> {
177202 }
178203
179204 if ( firstItem ) {
180- console . log ( 'setting active item to' , firstItem ) ;
181205 this . inputs . activeItem . set ( firstItem ) ;
182206 }
183207 }
0 commit comments