fix(chart): correct resizable modal resize direction for top/left handles - #43333
fix(chart): correct resizable modal resize direction for top/left handles#43333Lothnic wants to merge 1 commit into
Conversation
Code Review Agent Run #67580aActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| // mode lets us sync position with re-resizable's onResize so that resizing | ||
| // from top/left edges correctly repositions the modal (anchoring the | ||
| // opposite corner) instead of fighting over position. | ||
| const [position, setPosition] = useState({ x: 0, y: 0 }); |
There was a problem hiding this comment.
Suggestion: The controlled position is initialized only once and is never reset when the modal closes or reopens. With Ant Design retaining the CustomModal component, a modal reopened after being dragged retains its previous translation, unlike the prior unmounted draggable state, and can reopen displaced or outside the viewport. Reset the position when show transitions to false or when a new modal opening begins. [stale reference]
Severity Level: Major ⚠️
- ❌ Reopened View as table modals retain stale screen offsets.
- ❌ Dragged chart modals can reopen partly outside the viewport.
- ⚠️ Users must manually reposition displaced modal dialogs.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/packages/superset-ui-core/src/components/Modal/Modal.tsx
**Line:** 277:277
**Comment:**
*Stale Reference: The controlled position is initialized only once and is never reset when the modal closes or reopens. With Ant Design retaining the `CustomModal` component, a modal reopened after being dragged retains its previous translation, unlike the prior unmounted draggable state, and can reopen displaced or outside the viewport. Reset the position when `show` transitions to false or when a new modal opening begins.
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|
The flagged issue is correct. Because the You can implement this by adding a useEffect(() => {
if (!show) {
setPosition({ x: 0, y: 0 });
}
}, [show]);Would you like me to check the other comments on this PR and implement fixes for them as well? superset-frontend/packages/superset-ui-core/src/components/Modal/Modal.tsx |
85b67a9 to
7ff93a4
Compare
…dles Resizing modals from top or left edges (Drill by, Drill to detail, View as table) produced inverted-corner behavior and drift because react-draggable and re-resizable both tried to control position independently. Two changes in Modal.tsx: - Merge caller resizableConfig with defaults so callers that only set minHeight/minWidth/defaultSize don't silently enable all 8 resize handles (top, left, topLeft, etc.) - Switch Draggable to controlled mode and sync its position state with re-resizable's onResize callback, so resizing from top/left repositions the modal to anchor the opposite corner Also adds Modal.test.tsx covering config merge and position sync. Fixes apache#43320
7ff93a4 to
e78f11f
Compare
Code Review Agent Run #555f66Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Would you mind adding before/after screenshots or video to the PR description? I guess we have "before" on the Issue, but "after" would be useful. |
SUMMARY
Resizing modals from top or left edges (Drill by, Drill to detail, View as table) produced inverted-corner behavior and drift because
react-draggableandre-resizableboth tried to control position independently.Two changes in
Modal.tsx:resizableConfigwith defaults so callers that only setminHeight/minWidth/defaultSizedon't silently enable all 8 resize handles (top,left,topLeft, etc.)Draggableto controlled mode and sync its position state withre-resizable'sonResizecallback, so resizing from top/left repositions the modal to anchor the opposite cornerBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: Dragging from top-left corner resizes from bottom-right instead, and resizing along one axis causes drift
After: Top-left corner correctly anchors the bottom-right, and resize direction matches the handle being dragged
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
Modal.test.tsx(all passing)CHECKLIST