Commit 43e798d
authored
fix(react-drag-drop): support dynamic root element IDs in DragDropCon… (#12240)
* fix(react-drag-drop): support dynamic root element IDs in DragDropContainer
Fixes #12217
- Replace hardcoded document.getElementById('root') with dynamic root element lookup
- Add getRootElement() helper that tries common root IDs: 'root', 'app', 'main', '__next'
- Fallback to document.body if no common root element is found
- Enables usage in applications with non-standard root element IDs (e.g., id="app")
This fix allows OCP 4.22 and other applications to use @patternfly/react-drag-drop
regardless of their React root element configuration.
* perf: memoize root element lookup to avoid repeated DOM queries
* fix(DragDropContainer): handle case when DOM is not available by returning null for root element
* feat(DragDropContainer): add appendTo prop for customizable drag overlay target1 parent 1e5d932 commit 43e798d
File tree
1 file changed
+7
-1
lines changed- packages/react-drag-drop/src/components/DragDrop
1 file changed
+7
-1
lines changedLines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
288 | 291 | | |
289 | 292 | | |
290 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
291 | 297 | | |
292 | 298 | | |
293 | 299 | | |
| |||
299 | 305 | | |
300 | 306 | | |
301 | 307 | | |
302 | | - | |
| 308 | + | |
303 | 309 | | |
304 | 310 | | |
305 | 311 | | |
| |||
0 commit comments