Skip to content

Commit 4cc4adc

Browse files
authored
fix: Use Vue 3 function refs for child field components (#13)
- Replace dynamic string refs with function refs for Vue 3 compatibility - Add fieldRefs data property to store child component references - Add setFieldRef() method to collect refs from function ref callbacks - Update fill() method to use fieldRefs object for accessing child components - Add cleanup for fieldRefs in beforeUnmount lifecycle hook The previous fix using :ref="'field-' + attribute" didn't work reliably in Vue 3's v-for loops. Function refs provide direct access to components.
1 parent 91a4b6e commit 4cc4adc

3 files changed

Lines changed: 42 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
All notable changes to `nova-dependency-container` will be documented in this file.
44

5+
## [1.0.14] - 2025-11-25
6+
7+
### Fixed
8+
- Fixed dependent field values not being saved on form submission (Vue 3 ref pattern)
9+
- The previous fix in v1.0.13 used dynamic string refs which don't work reliably in Vue 3 v-for loops
10+
11+
### Changed
12+
- Switched from dynamic string refs (`:ref="'field-' + field.attribute"`) to Vue 3 function refs (`:ref="(el) => setFieldRef(field.attribute, el)"`)
13+
- Added `fieldRefs` data property to store child field component references
14+
- Added `setFieldRef()` method to properly collect and manage child component refs
15+
- Updated `fill()` method to use the new `fieldRefs` object for accessing child components
16+
- Added cleanup for `fieldRefs` in `beforeUnmount` lifecycle hook
17+
18+
### Technical
19+
- Vue 3 requires function refs when using dynamic ref names in v-for loops
20+
- Dynamic string refs like `:ref="'field-' + x"` create arrays but are unreliable to access via `$refs[key]`
21+
- Function refs `:ref="(el) => refs[key] = el"` provide direct access to component instances
22+
523
## [1.0.13] - 2025-11-25
624

725
### Fixed

0 commit comments

Comments
 (0)