@@ -100,67 +100,68 @@ export function Group({
100100 // Register Group and child Panels/Separators with global state
101101 // Listen to global state for drag state related to this Group
102102 useIsomorphicLayoutEffect ( ( ) => {
103- if ( element !== null && panels . length > 0 ) {
104- const group : RegisteredGroup = {
105- defaultLayout,
106- disableCursor : ! ! disableCursor ,
107- disabled : ! ! disabled ,
108- element,
109- id,
110- inMemoryLastExpandedPanelSizes :
111- inMemoryLastExpandedPanelSizesRef . current ,
112- inMemoryLayouts : inMemoryLayoutsRef . current ,
113- orientation,
114- panels,
115- separators
116- } ;
117-
118- const unmountGroup = mountGroup ( group ) ;
119-
120- const globalState = read ( ) ;
121- const match = globalState . mountedGroups . get ( group ) ;
122- if ( match ) {
123- setLayout ( match . layout ) ;
124- onLayoutChangeStable ?.( match . layout ) ;
125- }
103+ if ( element === null || panels . length === 0 ) {
104+ return ;
105+ }
106+
107+ const group : RegisteredGroup = {
108+ defaultLayout,
109+ disableCursor : ! ! disableCursor ,
110+ disabled : ! ! disabled ,
111+ element,
112+ id,
113+ inMemoryLastExpandedPanelSizes : inMemoryLastExpandedPanelSizesRef . current ,
114+ inMemoryLayouts : inMemoryLayoutsRef . current ,
115+ orientation,
116+ panels,
117+ separators
118+ } ;
119+
120+ const unmountGroup = mountGroup ( group ) ;
126121
127- const removeInteractionStateChangeListener = eventEmitter . addListener (
128- "interactionStateChange" ,
129- ( interactionState ) => {
130- switch ( interactionState . state ) {
131- case "active" : {
132- setDragActive (
133- interactionState . hitRegions . some (
134- ( current ) => current . group === group
135- )
136- ) ;
137- break ;
138- }
139- default : {
140- setDragActive ( false ) ;
141- break ;
142- }
122+ const globalState = read ( ) ;
123+ const match = globalState . mountedGroups . get ( group ) ;
124+ if ( match ) {
125+ setLayout ( match . layout ) ;
126+ onLayoutChangeStable ?.( match . layout ) ;
127+ }
128+
129+ const removeInteractionStateChangeListener = eventEmitter . addListener (
130+ "interactionStateChange" ,
131+ ( interactionState ) => {
132+ switch ( interactionState . state ) {
133+ case "active" : {
134+ setDragActive (
135+ interactionState . hitRegions . some (
136+ ( current ) => current . group === group
137+ )
138+ ) ;
139+ break ;
143140 }
144- }
145- ) ;
146-
147- const removeMountedGroupsChangeEventListener = eventEmitter . addListener (
148- "mountedGroupsChange" ,
149- ( mountedGroups ) => {
150- const match = mountedGroups . get ( group ) ;
151- if ( match && match . derivedPanelConstraints . length > 0 ) {
152- setLayout ( match . layout ) ;
153- onLayoutChangeStable ?.( match . layout ) ;
141+ default : {
142+ setDragActive ( false ) ;
143+ break ;
154144 }
155145 }
156- ) ;
146+ }
147+ ) ;
148+
149+ const removeMountedGroupsChangeEventListener = eventEmitter . addListener (
150+ "mountedGroupsChange" ,
151+ ( mountedGroups ) => {
152+ const match = mountedGroups . get ( group ) ;
153+ if ( match && match . derivedPanelConstraints . length > 0 ) {
154+ setLayout ( match . layout ) ;
155+ onLayoutChangeStable ?.( match . layout ) ;
156+ }
157+ }
158+ ) ;
157159
158- return ( ) => {
159- unmountGroup ( ) ;
160- removeInteractionStateChangeListener ( ) ;
161- removeMountedGroupsChangeEventListener ( ) ;
162- } ;
163- }
160+ return ( ) => {
161+ unmountGroup ( ) ;
162+ removeInteractionStateChangeListener ( ) ;
163+ removeMountedGroupsChangeEventListener ( ) ;
164+ } ;
164165 } , [
165166 defaultLayout ,
166167 disableCursor ,
0 commit comments