EnxDev commented on code in PR #45234:
URL: https://github.com/apache/superset/pull/45234#discussion_r4298331551


##########
superset-frontend/plugins/preset-chart-deckgl/src/CategoricalDeckGLContainer.tsx:
##########
@@ -124,16 +160,32 @@ const CategoricalDeckGLContainer = (props: 
CategoricalDeckGLContainerProps) => {
     props.payload.form_data,
   );
   const [viewport, setViewport] = useState(getAdjustedViewport());
+  const featuresRef = useRef(props.payload.data.features);
 
   useEffect(() => {
+    const features = props.payload.data.features || [];
     if (props.payload.form_data !== stateFormData) {
-      const features = props.payload.data.features || [];
       const categories = getCategories(props.formData, features);
 
       setViewport(getAdjustedViewport());
       setStateFormData(props.payload.form_data);
       setCategories(categories);
+    } else if (props.payload.data.features !== featuresRef.current) {
+      // A dashboard auto-refresh keeps the chart mounted and swaps in new
+      // data without a new form_data, so new categories are merged into the
+      // legend here instead of being filtered out as unknown, and autozoom
+      // refits the map to the new rows.
+      setCategories(previous =>
+        reconcileCategories(
+          previous as Categories,
+          getCategories(props.formData, features),
+        ),
+      );
+      if (props.formData.autozoom) {

Review Comment:
   Confirmed, fixed in 344470ba40. The refit keys on the bounds of the points 
by value instead of the features array identity, in all three places that had 
the same check: `CategoricalDeckGLContainer`, `Polygon` and the `factory` 
component.
   
   One detail from checking it: a plain pan or zoom was not undone. With the 
same rows and size, the refit lands on a viewport equal to the one already 
fitted, and `DeckGLContainer` only resets its view state when the `viewport` 
prop changes by value. A tilt or rotate was undone, because `fitViewport` 
carries the new `bearing`/`pitch` into the result, so the value changes and the 
container snaps back to the fitted center and zoom.
   
   With the fix, re-running the transform on the same rows leaves the viewport 
state alone, and an auto-refresh whose rows cover another area still refits.
   
   Tests: one per component that writes a tilted viewport back with an equal 
but rebuilt features array and checks that the viewport passed to the container 
is still the fitted one. All three fail without the fix. The existing 
"refreshed response moves the map" tests still pass, and so does the rest of 
the deck.gl suite (469).



-- 
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.

To unsubscribe, e-mail: [email protected]

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