@@ -9,12 +9,14 @@ type BlockNavigationState = {
99 panelOrder : PanelId [ ]
1010 panels : Map < PanelId , RoamPanel >
1111 focusedPanel : PanelIndex
12+ lastFocusedSidebarPanel : PanelIndex
1213}
1314
1415const state : BlockNavigationState = {
1516 panelOrder : [ ] ,
1617 panels : new Map ( ) ,
1718 focusedPanel : 0 ,
19+ lastFocusedSidebarPanel : 1 ,
1820}
1921
2022/**
@@ -26,7 +28,7 @@ type PanelIndex = number
2628type PanelElement = HTMLElement
2729
2830const PANEL_CSS_CLASS = 'roam-toolkit--panel'
29- const PANEL_SELECTOR = `.${ PANEL_CSS_CLASS } , ${ Selectors . sidebarContent } `
31+ const PANEL_SELECTOR = `.${ PANEL_CSS_CLASS } , ${ Selectors . sidebarPage } `
3032
3133/**
3234 * A "Panel" is a viewport that contains blocks. For now, there is just
@@ -121,8 +123,11 @@ export class RoamPanel {
121123 }
122124
123125 select ( ) {
126+ if ( state . focusedPanel > 0 ) {
127+ state . lastFocusedSidebarPanel = state . focusedPanel
128+ }
124129 state . focusedPanel = state . panelOrder . indexOf ( this . element )
125- this . element . scrollIntoView ( { behavior : 'smooth' } )
130+ this . element . scrollIntoView ( )
126131 }
127132
128133 static selected ( ) : RoamPanel {
@@ -144,6 +149,10 @@ export class RoamPanel {
144149 return RoamPanel . at ( 0 )
145150 }
146151
152+ static previousSidebarPanel ( ) : RoamPanel {
153+ return RoamPanel . at ( state . lastFocusedSidebarPanel )
154+ }
155+
147156 static previousPanel ( ) : RoamPanel {
148157 return RoamPanel . at ( state . focusedPanel - 1 )
149158 }
0 commit comments