Skip to content

Conversation

eschutho
Copy link
Member

Summary

Fixes DOM error NotFoundError: Failed to execute 'insertBefore' on 'Node' in DatasourceModal by replacing imperative modal updates with declarative React state management.

Problem

The DatasourceModal component was storing modal instances from Modal.useModal() and calling .update() on them imperatively. This caused DOM manipulation conflicts with React's reconciliation process, leading to the error when React tried to insert DOM nodes that were no longer children of their expected parents.

Solution

  • Convert ref to state: Changed syncColumnsRef to syncColumns state variable for proper React reactivity
  • Remove imperative updates: Eliminated confirmModal.update() calls that manipulated DOM outside React's control
  • Simplify modal creation: Modal content now updates naturally through React re-renders
  • Fix dependencies: Removed circular dependency in getSaveDialog callback
  • Add tests: Created comprehensive tests to verify proper hook usage and prevent regressions

Test Plan

  • All existing DatasourceModal tests pass (14/14)
  • New tests verify Modal.useModal hook usage instead of direct Modal.confirm
  • Tests confirm modal interactions work without DOM errors
  • TypeScript compilation successful
  • Pre-commit hooks pass (ESLint, type checking)

Technical Details

Before: Modal content was updated imperatively:

const [confirmModal, setConfirmModal] = useState(null);
// ...
confirmModal.update({ content: getSaveDialog() }); // ❌ DOM manipulation

After: Modal content updates declaratively:

const [syncColumns, setSyncColumns] = useState(false);
// Modal re-renders naturally when syncColumns state changes ✅

🤖 Generated with Claude Code

@dosubot dosubot bot added change:frontend Requires changing the frontend frontend:refactor Related to refactoring the frontend labels Sep 24, 2025
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've completed my review and didn't find any issues.

Files scanned
File Path Reviewed
superset-frontend/src/dashboard/components/EmbeddedModal/index.tsx
superset-frontend/src/components/Datasource/DatasourceModal/index.tsx
superset-frontend/src/pages/ThemeList/index.tsx

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

…ve state

Fixes DOM error "Failed to execute 'insertBefore' on 'Node'" by replacing
imperative modal.update() calls with React state management.

Changes:
- Convert syncColumnsRef to syncColumns state variable
- Remove confirmModal state and imperative update calls
- Simplify modal creation to not store instance
- Add tests to verify useModal hook usage and prevent regressions
- Remove unused useRef import

The modal content now updates declaratively through React re-renders
instead of direct DOM manipulation, eliminating insertion conflicts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@eschutho eschutho force-pushed the fix/datasource-modal-dom-error branch from ebbf139 to b44ec86 Compare September 24, 2025 01:10
@eschutho eschutho added the 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR label Sep 24, 2025
@github-actions github-actions bot added 🎪 b44ec86 🚦 building Environment b44ec86 status: building 🎪 b44ec86 📅 2025-09-24T01-12 Environment b44ec86 created at 2025-09-24T01-12 🎪 b44ec86 ⌛ 48h Environment b44ec86 expires after 48h and removed 🎪 ⚡ showtime-trigger-start Create new ephemeral environment for this PR labels Sep 24, 2025
Copy link
Contributor

🎪 Showtime is building environment on GHA for b44ec86

@github-actions github-actions bot added 🎪 b44ec86 🤡 eschutho Environment b44ec86 requested by eschutho 🎪 b44ec86 🚦 deploying Environment b44ec86 status: deploying 🎪 b44ec86 🚦 running Environment b44ec86 status: running 🎪 🎯 b44ec86 Active environment pointer - b44ec86 is receiving traffic 🎪 b44ec86 🌐 52.12.3.102:8080 Environment b44ec86 URL: http://52.12.3.102:8080 (click to visit) and removed 🎪 b44ec86 🚦 building Environment b44ec86 status: building 🎪 b44ec86 🚦 deploying Environment b44ec86 status: deploying 🎪 b44ec86 🚦 running Environment b44ec86 status: running 🎪 🎯 b44ec86 Active environment pointer - b44ec86 is receiving traffic labels Sep 24, 2025
Copy link
Contributor

🎪 Showtime deployed environment on GHA for b44ec86

Environment: http://52.12.3.102:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

@github-actions github-actions bot removed 🎪 b44ec86 🤡 eschutho Environment b44ec86 requested by eschutho 🎪 b44ec86 🌐 52.12.3.102:8080 Environment b44ec86 URL: http://52.12.3.102:8080 (click to visit) 🎪 b44ec86 ⌛ 48h Environment b44ec86 expires after 48h 🎪 b44ec86 🚦 running Environment b44ec86 status: running 🎪 b44ec86 📅 2025-09-24T01-12 Environment b44ec86 created at 2025-09-24T01-12 labels Sep 26, 2025
Follow testing guidelines to avoid nesting when testing.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@eschutho eschutho merged commit 82e2bc6 into master Sep 27, 2025
82 of 86 checks passed
@eschutho eschutho deleted the fix/datasource-modal-dom-error branch September 27, 2025 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:frontend Requires changing the frontend frontend:refactor Related to refactoring the frontend size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants