@@ -2155,13 +2155,44 @@ export const getActions = (
2155
2155
actionFunction : ( ) => {
2156
2156
// We turn off editing mode, if it is on
2157
2157
setEditorState ( undefined ) ;
2158
- setUIState ( prevUIState => {
2159
- const sheetIndex = prevUIState . selectedSheetIndex ;
2160
- return {
2161
- ...prevUIState ,
2162
- selectedSheetIndex : sheetIndex < sheetDataArray . length - 1 ? sheetIndex + 1 : 0
2158
+
2159
+ const selectedSheetIndex = uiState . selectedSheetIndex ;
2160
+ const selectedGraphID = uiState . currOpenTaskpane . type === TaskpaneType . GRAPH ? uiState . currOpenTaskpane . openGraph . graphID : undefined ;
2161
+
2162
+ if ( selectedGraphID !== undefined ) {
2163
+ const graphIndex = analysisData . graphDataArray . findIndex ( graphData => graphData . graph_id === selectedGraphID ) ;
2164
+ if ( graphIndex === - 1 || graphIndex === analysisData . graphDataArray . length - 1 ) {
2165
+ setUIState ( prevUIState => {
2166
+ return {
2167
+ ...prevUIState ,
2168
+ currOpenTaskpane : { type : TaskpaneType . NONE } ,
2169
+ selectedTabType : 'data' ,
2170
+ selectedSheetIndex : 0
2171
+ }
2172
+ } ) ;
2173
+ } else {
2174
+ void openGraphSidebar ( setUIState , uiState , setEditorState , sheetDataArray , mitoAPI , {
2175
+ type : 'existing_graph' ,
2176
+ graphID : analysisData . graphDataArray [ graphIndex + 1 ] . graph_id
2177
+ } )
2178
+ return ;
2163
2179
}
2164
- } )
2180
+ } else {
2181
+ if ( selectedSheetIndex === sheetDataArray . length - 1 && analysisData . graphDataArray . length > 0 ) {
2182
+ void openGraphSidebar ( setUIState , uiState , setEditorState , sheetDataArray , mitoAPI , {
2183
+ type : 'existing_graph' ,
2184
+ graphID : analysisData . graphDataArray [ 0 ] . graph_id
2185
+ } )
2186
+ return ;
2187
+ } else {
2188
+ setUIState ( prevUIState => {
2189
+ return {
2190
+ ...prevUIState ,
2191
+ selectedSheetIndex : selectedSheetIndex === sheetDataArray . length - 1 ? 0 : selectedSheetIndex + 1
2192
+ }
2193
+ } ) ;
2194
+ }
2195
+ }
2165
2196
} ,
2166
2197
isDisabled : ( ) => { return defaultActionDisabledMessage } ,
2167
2198
searchTerms : [ 'sheet' , 'index' , 'next' , 'forward' ] ,
@@ -2174,13 +2205,44 @@ export const getActions = (
2174
2205
actionFunction : ( ) => {
2175
2206
// We turn off editing mode, if it is on
2176
2207
setEditorState ( undefined ) ;
2177
- setUIState ( prevUIState => {
2178
- const sheetIndex = prevUIState . selectedSheetIndex ;
2179
- return {
2180
- ...prevUIState ,
2181
- selectedSheetIndex : sheetIndex > 0 ? sheetIndex - 1 : sheetDataArray . length - 1
2208
+
2209
+ const selectedSheetIndex = uiState . selectedSheetIndex ;
2210
+ const selectedGraphID = uiState . currOpenTaskpane . type === TaskpaneType . GRAPH ? uiState . currOpenTaskpane . openGraph . graphID : undefined ;
2211
+
2212
+ if ( selectedGraphID !== undefined ) {
2213
+ const graphIndex = analysisData . graphDataArray . findIndex ( graphData => graphData . graph_id === selectedGraphID ) ;
2214
+ if ( graphIndex === - 1 || graphIndex === 0 ) {
2215
+ setUIState ( prevUIState => {
2216
+ return {
2217
+ ...prevUIState ,
2218
+ currOpenTaskpane : { type : TaskpaneType . NONE } ,
2219
+ selectedTabType : 'data' ,
2220
+ selectedSheetIndex : sheetDataArray . length - 1
2221
+ }
2222
+ } ) ;
2223
+ } else {
2224
+ void openGraphSidebar ( setUIState , uiState , setEditorState , sheetDataArray , mitoAPI , {
2225
+ type : 'existing_graph' ,
2226
+ graphID : analysisData . graphDataArray [ graphIndex - 1 ] . graph_id
2227
+ } )
2228
+ return ;
2182
2229
}
2183
- } )
2230
+ } else {
2231
+ if ( selectedSheetIndex === 0 && analysisData . graphDataArray . length > 0 ) {
2232
+ void openGraphSidebar ( setUIState , uiState , setEditorState , sheetDataArray , mitoAPI , {
2233
+ type : 'existing_graph' ,
2234
+ graphID : analysisData . graphDataArray [ analysisData . graphDataArray . length - 1 ] . graph_id
2235
+ } )
2236
+ return ;
2237
+ } else {
2238
+ setUIState ( prevUIState => {
2239
+ return {
2240
+ ...prevUIState ,
2241
+ selectedSheetIndex : selectedSheetIndex === 0 ? sheetDataArray . length - 1 : selectedSheetIndex - 1
2242
+ }
2243
+ } ) ;
2244
+ }
2245
+ }
2184
2246
} ,
2185
2247
isDisabled : ( ) => { return defaultActionDisabledMessage } ,
2186
2248
searchTerms : [ 'sheet' , 'index' , 'previous' , 'last' ] ,
0 commit comments