@@ -167,13 +167,12 @@ export const QueryBuilderProvider = ({
167
167
return true ;
168
168
} ;
169
169
170
- const [ rootCondition , setRootCondition ] = useState < AndOrMetadataInput > ( ( ) => getInitialQuery ( ) ) ;
170
+ const [ rootCondition , setRootCondition ] = useState < AndOrMetadataInput > ( getInitialQuery ) ;
171
171
const [ isDisplayableInSimpleMode , setIsDisplayableInSimpleMode ] = useState < boolean > (
172
- checkIfConditionIsDisplayableInSimpleMode ( queryInput . query )
172
+ ( ) => checkIfConditionIsDisplayableInSimpleMode ( queryInput . query )
173
173
) ;
174
- const [ isCompoundModeForced , setIsCompoundModeForced ] = useState < boolean > ( false ) ;
175
174
const [ isSimpleMode , setIsSimpleMode ] = useState < boolean > (
176
- ( ) => isDisplayableInSimpleMode && ! isCompoundModeForced
175
+ isDisplayableInSimpleMode
177
176
) ;
178
177
179
178
useEffect ( ( ) => {
@@ -191,15 +190,24 @@ export const QueryBuilderProvider = ({
191
190
} , [ rootCondition ] ) ;
192
191
193
192
function onToggleQueryMode ( ) {
194
- setIsCompoundModeForced ( ! isCompoundModeForced ) ;
193
+ setIsSimpleMode ( ( isSimpleMode ) => {
194
+ if ( isSimpleMode ) {
195
+ return false ;
196
+ } else {
197
+ return isDisplayableInSimpleMode ;
198
+ }
199
+ } ) ;
195
200
}
196
201
197
202
useEffect ( ( ) => {
198
- console . log ( 'set is simple mode' , isDisplayableInSimpleMode && ! isCompoundModeForced ) ;
199
- console . log ( 'is compound mode forced' , isCompoundModeForced ) ;
200
- console . log ( 'is displayable in simple mode' , isDisplayableInSimpleMode ) ;
201
- setIsSimpleMode ( isDisplayableInSimpleMode && ! isCompoundModeForced ) ;
202
- } , [ isCompoundModeForced , isDisplayableInSimpleMode ] ) ;
203
+ setIsSimpleMode ( ( isSimpleMode ) => {
204
+ if ( isSimpleMode ) {
205
+ return isDisplayableInSimpleMode ;
206
+ } else {
207
+ return false ;
208
+ }
209
+ } ) ;
210
+ } , [ isDisplayableInSimpleMode ] ) ;
203
211
204
212
//This function is used to remove the root and wrapper, if it was added for ui purposes and not needed anymore
205
213
const removeRootAndBlockIfWasAddedAndNotNeeded = ( condition : AndOrMetadataInput | null ) => {
0 commit comments