@@ -27,20 +27,20 @@ type LayoutActionType =
2727 | 'ACTION_SET_TREE_LIST_TOGGLE'
2828 | 'ACTION_SET_TREE_LIST_HORIZONTAL_FRACTION'
2929 | 'ACTION_SET_INSPECTED_ELEMENT_TOGGLE'
30- | 'ACTION_SET_INSPECTED_ELEMENT_HORIZONTAL_PERCENTAGE '
31- | 'ACTION_SET_INSPECTED_ELEMENT_VERTICAL_PERCENTAGE ' ;
30+ | 'ACTION_SET_INSPECTED_ELEMENT_HORIZONTAL_FRACTION '
31+ | 'ACTION_SET_INSPECTED_ELEMENT_VERTICAL_FRACTION ' ;
3232type LayoutAction = {
3333 type : LayoutActionType ,
3434 payload : any ,
3535} ;
3636
37- interface LayoutState {
38- treeListHidden: boolean ;
39- treeListHorizontalFraction: number ;
40- inspectedElementHidden: boolean ;
41- inspectedElementHorizontalFraction: number ;
42- inspectedElementVerticalFraction: number ;
43- }
37+ type LayoutState = {
38+ treeListHidden : boolean ,
39+ treeListHorizontalFraction : number ,
40+ inspectedElementHidden : boolean ,
41+ inspectedElementHorizontalFraction : number ,
42+ inspectedElementVerticalFraction : number ,
43+ } ;
4444type LayoutDispatch = ( action : LayoutAction ) => void ;
4545
4646function SuspenseTreeList ( ) {
@@ -67,6 +67,7 @@ function ToggleTreeList({
6767 onClick = { ( ) =>
6868 dispatch ( {
6969 type : 'ACTION_SET_TREE_LIST_TOGGLE' ,
70+ payload : null ,
7071 } )
7172 }
7273 title = { state . treeListHidden ? 'Show Tree List' : 'Hide Tree List' } >
@@ -103,6 +104,7 @@ function ToggleInspectedElement({
103104 onClick = { ( ) =>
104105 dispatch ( {
105106 type : 'ACTION_SET_INSPECTED_ELEMENT_TOGGLE' ,
107+ payload : null ,
106108 } )
107109 }
108110 title = {
@@ -116,7 +118,7 @@ function ToggleInspectedElement({
116118}
117119
118120function SuspenseTab ( _ : { } ) {
119- const [ state , dispatch ] = useReducer < LayoutState , null , LayoutActionType > (
121+ const [ state , dispatch ] = useReducer < LayoutState , null , LayoutAction > (
120122 layoutReducer ,
121123 null ,
122124 initLayoutState ,
@@ -184,17 +186,17 @@ function SuspenseTab(_: {}) {
184186 treeListHorizontalFraction ,
185187 ] ) ;
186188
187- const onResizeStart = event => {
189+ const onResizeStart = ( event : SyntheticPointerEvent < HTMLElement > ) => {
188190 const element = event . currentTarget ;
189191 element . setPointerCapture ( event . pointerId ) ;
190192 } ;
191193
192- const onResizeEnd = event => {
194+ const onResizeEnd = ( event : SyntheticPointerEvent < HTMLElement > ) => {
193195 const element = event . currentTarget ;
194196 element . releasePointerCapture ( event . pointerId ) ;
195197 } ;
196198
197- const onResizeTree = event => {
199+ const onResizeTree = ( event : SyntheticPointerEvent < HTMLElement > ) => {
198200 const element = event . currentTarget ;
199201 const isResizing = element . hasPointerCapture ( event . pointerId ) ;
200202 if ( ! isResizing ) {
@@ -245,7 +247,7 @@ function SuspenseTab(_: {}) {
245247 }
246248 } ;
247249
248- const onResizeTreeList = event => {
250+ const onResizeTreeList = ( event : SyntheticPointerEvent < HTMLElement > ) => {
249251 const element = event . currentTarget ;
250252 const isResizing = element . hasPointerCapture ( event . pointerId ) ;
251253 if ( ! isResizing ) {
@@ -355,10 +357,7 @@ const VERTICAL_TREE_MODE_MAX_WIDTH = 600;
355357const MINIMUM_TREE_SIZE = 100 ;
356358const MINIMUM_TREE_LIST_SIZE = 100 ;
357359
358- function layoutReducer (
359- state : LayoutState ,
360- action : LayoutActionType ,
361- ) : LayoutState {
360+ function layoutReducer ( state : LayoutState , action : LayoutAction ) : LayoutState {
362361 switch ( action . type ) {
363362 case 'ACTION_SET_TREE_LIST_TOGGLE' :
364363 return {
@@ -430,15 +429,17 @@ function getTreeOrientation(
430429}
431430
432431function setResizeCSSVariable (
433- resizeElement : HTMLElement ,
432+ resizeElement : null | HTMLElement ,
434433 name : 'tree' | 'tree-list' ,
435434 orientation : null | Orientation ,
436435 percentage : number ,
437436) : void {
438- resizeElement . style . setProperty (
439- `--${ orientation } -resize-${ name } -percentage` ,
440- `${ percentage } %` ,
441- ) ;
437+ if ( resizeElement !== null && orientation !== null ) {
438+ resizeElement . style . setProperty (
439+ `--${ orientation } -resize-${ name } -percentage` ,
440+ `${ percentage } %` ,
441+ ) ;
442+ }
442443}
443444
444445export default ( portaledContent ( SuspenseTab ) : React$ComponentType < { } > ) ;
0 commit comments