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


##########
superset-frontend/src/dashboard/components/DashboardGrid.tsx:
##########
@@ -148,18 +166,35 @@ function DashboardGrid({
 
   const handleResizeStart = useCallback((): void => {
     setIsResizing(true);
+    setRowGuideTop(null);
   }, []);
 
+  const getRowGuidePosition = useCallback(
+    (resizeRef: HTMLElement | null): number | null => {
+      if (resizeRef && gridRef.current) {
+        return (
+          resizeRef.getBoundingClientRect().bottom -
+          gridRef.current.getBoundingClientRect().top -
+          2
+        );
+      }
+      return null;
+    },
+    [],
+  );
+
   const handleResize = useCallback(
     (
       _event: MouseEvent | TouchEvent,
-      _direction: string,
-      _elementRef: HTMLElement,
+      direction: string,
+      elementRef: HTMLElement,
       _delta: { width: number; height: number },
     ): void => {
-      // no-op: resize position tracking not implemented
+      if (direction.toLowerCase().includes(BOTTOM_RESIZE_DIRECTION)) {
+        setRowGuideTop(getRowGuidePosition(elementRef));
+      }

Review Comment:
   **Suggestion:** The resize handler updates React state on every 
mousemove/touchmove during bottom resizing, which forces the entire dashboard 
grid subtree to re-render at drag frequency and can cause noticeable resize lag 
on dashboards with many components. Limit updates (for example, only when the 
computed top actually changes or via throttling/ref-driven style updates) to 
avoid high-frequency full-grid re-renders. [performance]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Dashboard grid re-renders every bottom-drag pointer event.
   - ⚠️ Large dashboards may feel laggy during vertical resize.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Render a dashboard in edit mode so `DashboardGrid` is mounted with 
`editMode={true}`
   and children, as in 
`superset-frontend/src/dashboard/components/DashboardGrid.tsx:145-157`
   and the mapping of children at
   `superset-frontend/src/dashboard/components/DashboardGrid.tsx:344-357`.
   
   2. For a chart component, follow the render chain: `DashboardGrid` renders
   `DashboardComponent` (container) with `onResizeStart`, `onResize`, and 
`onResizeStop`
   props at `DashboardGrid.tsx:344-357`, `DashboardComponent` passes these 
through to grid
   components at 
`superset-frontend/src/dashboard/containers/DashboardComponent.tsx:91-184`,
   and `ChartHolder` then passes the same callbacks into `ResizableContainer` at
   
`superset-frontend/src/dashboard/components/gridComponents/ChartHolder/ChartHolder.tsx:16-27`
   (snippet header “Showing lines 60 to 179”).
   
   3. When the user drags the bottom resize handle of the chart in the UI, 
`re-resizable`
   invokes `ResizableContainer`’s `onResize` prop repeatedly with `direction 
=== 'bottom'`
   (as mocked in `DashboardGrid` tests at
   `superset-frontend/src/dashboard/components/DashboardGrid.test.tsx:24-27`, 
where
   `onMouseMove` calls `onResize(null, 'bottom', mockResizeElementRef, { width: 
0, height: 10
   })`).
   
   4. Each `onResize` call from `ResizableContainer` is forwarded through 
`ChartHolder` and
   `DashboardComponent` back to `DashboardGrid.handleResize` at 
`DashboardGrid.tsx:186-198`,
   where the branch at `193-195` runs on every event, calling
   `setRowGuideTop(getRowGuidePosition(elementRef))`. Because `rowGuideTop` is 
local state on
   `DashboardGrid` and used in the JSX (row guide rendering at 
`DashboardGrid.tsx:389-393`),
   every pointer move during a bottom drag triggers a `DashboardGrid` state 
update and a full
   re-render of the grid layout, including mapping all children and styled 
wrappers. On
   dashboards with many components, this per-event re-render can cause visible 
lag during
   resize.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7a2e79cec17144e4a0d4a7a600c785b1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=7a2e79cec17144e4a0d4a7a600c785b1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/dashboard/components/DashboardGrid.tsx
   **Line:** 193:195
   **Comment:**
        *Performance: The resize handler updates React state on every 
mousemove/touchmove during bottom resizing, which forces the entire dashboard 
grid subtree to re-render at drag frequency and can cause noticeable resize lag 
on dashboards with many components. Limit updates (for example, only when the 
computed top actually changes or via throttling/ref-driven style updates) to 
avoid high-frequency full-grid re-renders.
   
   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.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41079&comment_hash=bc1143b852b009859e86a789f72aecc6142e3a2dbb3a31e982ca5df87375ebfd&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41079&comment_hash=bc1143b852b009859e86a789f72aecc6142e3a2dbb3a31e982ca5df87375ebfd&reaction=dislike'>👎</a>



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