Skip to content

fix: Add DOM-based watching for Flexible fields (#4)#11

Merged
iamgerwin merged 2 commits into
mainfrom
fix/issue-4-flexible-sibling-field-detection
Nov 25, 2025
Merged

fix: Add DOM-based watching for Flexible fields (#4)#11
iamgerwin merged 2 commits into
mainfrom
fix/issue-4-flexible-sibling-field-detection

Conversation

@iamgerwin

Copy link
Copy Markdown
Owner

Summary

Nova's global field-changed events are not emitted by fields inside nova-flexible-content layouts. This PR adds DOM-based watching as a fallback.

Root Cause

From the debug logs, we can see that:

  • The container mounts correctly with the Flexible context
  • Dependencies are configured correctly
  • BUT no field-changed events are received when changing the Type field

This is because fields inside Flexible layouts don't emit to Nova's global event bus.

Solution

Added DOM-based watching to detect field changes directly:

  1. setupDOMWatching(): Attaches change and input event listeners to form elements
  2. loadInitialValuesFromDOM(): Gets field values directly from DOM elements at mount time
  3. findFlexibleContainer(): Locates the Flexible layout wrapper element
  4. handleDOMChange(): Processes native DOM change events
  5. MutationObserver: Detects dynamically added elements

Files Changed

File Changes
resources/js/components/FormField.vue Added DOM watching methods
dist/js/field.js Rebuilt assets

Fixes #4

Nova's global field-changed events are not emitted by fields inside
nova-flexible-content layouts. Added fallback DOM watching:

- setupDOMWatching(): Listen for native change/input events
- loadInitialValuesFromDOM(): Get values directly from DOM elements
- findFlexibleContainer(): Locate the Flexible layout wrapper
- handleDOMChange(): Process native DOM events
- MutationObserver: Detect dynamically added elements
- Proper cleanup on unmount
@iamgerwin iamgerwin merged commit 7b151cc into main Nov 25, 2025
0 of 2 checks passed
@iamgerwin iamgerwin deleted the fix/issue-4-flexible-sibling-field-detection branch November 25, 2025 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NovaDependencyContainer inside Flexible field not showing dependent fields

1 participant