codeant-ai-for-open-source[bot] commented on code in PR #37221:
URL: https://github.com/apache/superset/pull/37221#discussion_r2710712184


##########
superset-frontend/plugins/legacy-preset-chart-deckgl/src/Multi/Multi.tsx:
##########
@@ -115,26 +115,31 @@ const DeckMulti = (props: DeckMultiProps) => {
 
   const getAdjustedViewport = useCallback(() => {
     let viewport = { ...props.viewport };
-    const points = [
-      ...getPointsPolygon(props.payload.data.features.deck_polygon || []),
-      ...getPointsPath(props.payload.data.features.deck_path || []),
-      ...getPointsGrid(props.payload.data.features.deck_grid || []),
-      ...getPointsScatter(props.payload.data.features.deck_scatter || []),
-      ...getPointsContour(props.payload.data.features.deck_contour || []),
-      ...getPointsHeatmap(props.payload.data.features.deck_heatmap || []),
-      ...getPointsHex(props.payload.data.features.deck_hex || []),
-      ...getPointsArc(props.payload.data.features.deck_arc || []),
-      ...getPointsGeojson(props.payload.data.features.deck_geojson || []),
-      ...getPointsScreengrid(props.payload.data.features.deck_screengrid || 
[]),
-    ];
-
-    if (props.formData) {
-      viewport = fitViewport(viewport, {
-        width: props.width,
-        height: props.height,
-        points,
-      });
+    
+    // Only apply auto zoom if the autozoom setting is enabled
+    if (props.formData.autozoom) {

Review Comment:
   **Suggestion:** Logic bug: the new code treats an absent `autozoom` setting 
(undefined) as disabled because it checks `if (props.formData.autozoom)`, but 
the intended default behavior is enabled; change the condition to treat only an 
explicit `false` as disabling auto-zoom. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Explore deck.gl Multiple Layers map not auto-zooming.
   - ⚠️ Inconsistent behavior vs other deck.gl charts.
   ```
   </details>
   
   ```suggestion
       if (props.formData?.autozoom !== false) {
   ```
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open a saved dashboard or chart created before this PR that uses the 
"deck.gl Multiple
   Layers" visualization (Explore → choose dataset → select "deck.gl Multiple 
Layers"). The
   saved chart's formData often lacks the new control key `autozoom`.
   
   2. Component mounts and initializes viewport: Multi.tsx defines 
getAdjustedViewport()
   (Multi.tsx lines 116-145 in the PR hunk) and then calls it during state 
initialization via
   useState(getAdjustedViewport()) (immediately after getAdjustedViewport 
definition in the
   same file).
   
   3. Inside getAdjustedViewport(), the code at Multi.tsx line 120 executes the 
condition `if
   (props.formData.autozoom) {`. When `autozoom` is absent from saved formData 
(i.e.,
   undefined), this condition is false and the auto-fit code path is skipped.
   
   4. Observable result: the map does not auto-zoom to data bounds for that 
chart instance
   even though the intended default is to auto-zoom. This can be reproduced by 
loading any
   legacy saved Multi Layers chart whose stored formData does not include 
`autozoom`.
   
   Note: The reproduction follows the actual call chain in this file: component 
mount →
   getAdjustedViewport() (Multi.tsx:116-145) → conditional check at line 120 → 
fitViewport is
   skipped.
   ```
   </details>
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/plugins/legacy-preset-chart-deckgl/src/Multi/Multi.tsx
   **Line:** 120:120
   **Comment:**
        *Logic Error: Logic bug: the new code treats an absent `autozoom` 
setting (undefined) as disabled because it checks `if 
(props.formData.autozoom)`, but the intended default behavior is enabled; 
change the condition to treat only an explicit `false` as disabling auto-zoom.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   ```
   </details>



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