@@ -114,6 +114,49 @@ export class AlertTable extends React.Component<
114114 ) ;
115115 }
116116
117+ private getNewSelection (
118+ key : Keys . ResultKey | undefined ,
119+ direction : NavigationDirection ,
120+ ) : Keys . ResultKey {
121+ if ( key === undefined ) {
122+ return { resultIndex : 0 } ;
123+ }
124+ const { resultIndex, pathIndex, pathNodeIndex } = key ;
125+ switch ( direction ) {
126+ case NavigationDirection . up :
127+ case NavigationDirection . down : {
128+ const delta = direction === NavigationDirection . up ? - 1 : 1 ;
129+ if ( key . pathNodeIndex !== undefined ) {
130+ return {
131+ resultIndex,
132+ pathIndex : key . pathIndex ,
133+ pathNodeIndex : key . pathNodeIndex + delta ,
134+ } ;
135+ } else if ( pathIndex !== undefined ) {
136+ return { resultIndex, pathIndex : pathIndex + delta } ;
137+ } else {
138+ return { resultIndex : resultIndex + delta } ;
139+ }
140+ }
141+ case NavigationDirection . left :
142+ if ( key . pathNodeIndex !== undefined ) {
143+ return { resultIndex, pathIndex : key . pathIndex } ;
144+ } else if ( pathIndex !== undefined ) {
145+ return { resultIndex } ;
146+ } else {
147+ return key ;
148+ }
149+ case NavigationDirection . right :
150+ if ( pathIndex === undefined ) {
151+ return { resultIndex, pathIndex : 0 } ;
152+ } else if ( pathNodeIndex === undefined ) {
153+ return { resultIndex, pathIndex, pathNodeIndex : 0 } ;
154+ } else {
155+ return key ;
156+ }
157+ }
158+ }
159+
117160 private handleNavigationEvent ( event : NavigateMsg ) {
118161 this . setState ( ( prevState ) => {
119162 const key = this . getNewSelection ( prevState . selectedItem , event . direction ) ;
@@ -177,49 +220,6 @@ export class AlertTable extends React.Component<
177220 } ) ;
178221 }
179222
180- private getNewSelection (
181- key : Keys . ResultKey | undefined ,
182- direction : NavigationDirection ,
183- ) : Keys . ResultKey {
184- if ( key === undefined ) {
185- return { resultIndex : 0 } ;
186- }
187- const { resultIndex, pathIndex, pathNodeIndex } = key ;
188- switch ( direction ) {
189- case NavigationDirection . up :
190- case NavigationDirection . down : {
191- const delta = direction === NavigationDirection . up ? - 1 : 1 ;
192- if ( key . pathNodeIndex !== undefined ) {
193- return {
194- resultIndex,
195- pathIndex : key . pathIndex ,
196- pathNodeIndex : key . pathNodeIndex + delta ,
197- } ;
198- } else if ( pathIndex !== undefined ) {
199- return { resultIndex, pathIndex : pathIndex + delta } ;
200- } else {
201- return { resultIndex : resultIndex + delta } ;
202- }
203- }
204- case NavigationDirection . left :
205- if ( key . pathNodeIndex !== undefined ) {
206- return { resultIndex, pathIndex : key . pathIndex } ;
207- } else if ( pathIndex !== undefined ) {
208- return { resultIndex } ;
209- } else {
210- return key ;
211- }
212- case NavigationDirection . right :
213- if ( pathIndex === undefined ) {
214- return { resultIndex, pathIndex : 0 } ;
215- } else if ( pathNodeIndex === undefined ) {
216- return { resultIndex, pathIndex, pathNodeIndex : 0 } ;
217- } else {
218- return key ;
219- }
220- }
221- }
222-
223223 componentDidUpdate ( ) {
224224 this . scroller . update ( ) ;
225225 }
0 commit comments