-
-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
@Ref
not being (fully) reactive makes sense, as $refs is not reactive (see vuejs/core#13168).
The suggested solution by the people over at the vuejs team, was to call useTemplateRefs(), which is available since Vue 3.5 (I think).
I've tried playing around with this function, ignoring the possible unavailability, but haven't figured it out, as unfortunately, I'm not well versed with either this repo nor the vuejs/core repo.
Note that I've only been able to actually reproduce this when using some slots. If needed, I can try to make a (more) minimal reproduction than our entire application.
For completeness, I've tried without success:
Index: src/option/ref.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/option/ref.ts b/src/option/ref.ts
--- a/src/option/ref.ts (revision 38028583b8c393e9c2ed1e7cab9c5585219e9acf)
+++ b/src/option/ref.ts (date 1744051041570)
@@ -2,6 +2,8 @@
import { type OptionBuilder, applyAccessors } from '../optionBuilder'
import { obtainSlot, optoinNullableMemberDecorator } from '../utils'
import { compatibleMemberDecorator } from '../deco3/utils'
+import { useTemplateRef } from 'vue'
+
export const decorator = optoinNullableMemberDecorator(function (proto: any, name: string) {
const slot = obtainSlot(proto)
const map = slot.obtainMap('ref')
@@ -26,6 +28,16 @@
set: undefined
})
})
+ const setupRefs = (): void => {
+ names.forEach((value, name) => {
+ const refKey = value === null ? name : value
+ useTemplateRef(refKey);
+ })
+ }
+
+ const oldSetup = optionBuilder.setup;
+ optionBuilder.setup = oldSetup ? (...args) => { setupRefs(); oldSetup(...args); } : setupRefs;
+
return data
})
Metadata
Metadata
Assignees
Labels
No labels