etr2460 commented on a change in pull request #10264:
URL: 
https://github.com/apache/incubator-superset/pull/10264#discussion_r451909445



##########
File path: superset-frontend/src/explore/controlUtils.js
##########
@@ -121,19 +123,31 @@ function handleMissingChoice(control) {
   return control;
 }
 
-export function getControlStateFromControlConfig(controlConfig, state, value) {
+export function getControlStateFromControlConfig(
+  controlConfig,
+  controlPanelState,
+  value,
+) {
   // skip invalid config values
   if (!controlConfig) {
     return null;
   }
-  const controlState = applyMapStateToPropsToControl(
-    { ...controlConfig },
-    state,
-  );
+  const controlState = { ...controlConfig };
+  // only apply mapStateToProps when control states have been initialized
+  if (controlPanelState.controls || !controlPanelState.isInitializing) {
+    applyMapStateToPropsToControl(controlState, controlPanelState);
+  }

Review comment:
       you could make this something like:
   ```typescript
   const controlStateWithControlPanelProps = controlPanelState.controls || 
!controlPanelState.isInitializing 
     ? applyMapStateToPropsToControl(controlState, controlPanelState)
     : controlState;
   ```
   
   and then use it below. With that context, it should be fairly clear that we 
want to continue to use the latest created state variable. especially since the 
function isn't massive, I don't think people would mistakenly use the old state 
in this function




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to