msyavuz opened a new pull request, #44303:
URL: https://github.com/apache/superset/pull/44303

   ### SUMMARY
   
   Dragging a container onto a component nested inside itself was a legal drop: 
`getDropPosition` only rejected a drop on the dragged component itself, never 
on one of its descendants. `reorderItem` then detached the subtree from its 
real parent and left the pair pointing at each other:
   
   ```
   COLUMN-x  children: [CHART-a, ROW-y]
   ROW-y     children: [COLUMN-x]      <- back-edge, whole clump detached from 
ROOT_ID
   ```
   
   Every repair path (`updateComponentParentsList`, hydration) walks down from 
`ROOT_ID`, so none of them reached the damage. The dashboard kept rendering and 
saving while the trapped chart silently disappeared. The filter scope modal is 
the one place that finds it, via `addInvisibleParents` following stale 
`meta.parents`, and it recursed until the stack blew — the `Maximum call stack 
size exceeded` that #39355 papered over with a `visited` guard.
   
   Two changes: forbid dropping a component into itself or any descendant 
(`getDropPosition`, plus the same check in the `MOVE_COMPONENT` reducer for a 
hand-built `dropResult`), and drop components unreachable from `ROOT_ID` on 
hydration and on both backend write paths, which repairs layouts that are 
corrupt today. Charts are resolved from the incoming positions *before* the 
repair, so a chart freed from a detached subtree keeps its `dashboard_slices` 
row and hydration places it back into the layout.
   
   Verified against a real corrupted export: the repair removes exactly the 
three detached components and leaves the other 300 byte-identical to a 
hand-repaired copy of the same dashboard.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Not applicable — no visual change. Before: a column dragged into a row 
inside itself vanishes and "Add or edit filters" throws `RangeError: Maximum 
call stack size exceeded`. After: the drop is refused, and an already-corrupt 
dashboard loses the detached nodes and gets its chart back.
   
   ### TESTING INSTRUCTIONS
   
   1. In edit mode, put a chart in a column, then add a row inside that same 
column.
   2. Drag the column onto the nested row. The drop is refused instead of 
detaching the column.
   3. For the repair path, save a dashboard whose `position_json` contains a 
component unreachable from `ROOT_ID`; it is dropped on save and a warning 
naming the dashboard and ids is logged.
   
   ```
   pytest tests/unit_tests/dashboards/layout_test.py
   cd superset-frontend && npm run test -- 
src/dashboard/util/removeUnreachableComponents.test.ts 
src/dashboard/util/getDropPosition.test.ts 
src/dashboard/reducers/dashboardLayout.test.ts
   ```
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue: No
   - [ ] Required feature flags: None
   - [x] Changes UI — drag and drop refuses self-nesting drops; no visual change
   - [ ] Includes DB Migration: No — `position_json` is repaired on write, no 
schema change
     - [ ] Migration is atomic, supports rollback & is backwards-compatible: N/A
     - [ ] Confirm DB migration upgrade and downgrade tested: N/A
     - [ ] Runtime estimates and downtime expectations provided: N/A
   - [ ] Introduces new feature or API: No
   - [ ] Removes existing feature or API: No


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