Skip to content

Commit d007e90

Browse files
fix(vue): accept null template refs so useTemplateRef type-checks
Vue 3.5's useTemplateRef() returns Ref<HTMLElement | null>, which the previous VueElement type rejected. Widen the ref value to include null (the runtime already waits for a non-null element before initializing) and reuse VueElement for the parent field. Convert the Vue Test1 component to useTemplateRef so the framework e2e suite exercises it. Co-authored-by: jf908 <2487520+jf908@users.noreply.github.com>
1 parent 46aa839 commit d007e90

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/vue/types.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { MaybeRef, Ref } from "vue";
22
import type { ParentConfig } from "../types";
33

4-
export type VueElement = HTMLElement | Ref<HTMLElement | undefined>;
4+
export type VueElement = HTMLElement | Ref<HTMLElement | null | undefined>;
55

66
export interface VueDragAndDropData<T> extends VueParentConfig<T> {
7-
parent: HTMLElement | Ref<HTMLElement | undefined>;
7+
parent: VueElement;
88
values: MaybeRef<Array<T>>;
99
}
1010

‎tests-frameworks/vue/components/Test1.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { ref } from "vue";
2+
import { ref, useTemplateRef } from "vue";
33
import { dragAndDrop } from "../../../src/vue/index";
44
55
const props = defineProps<{
@@ -18,7 +18,7 @@ const values = ref([
1818
},
1919
]);
2020
21-
const parent = ref();
21+
const parent = useTemplateRef<HTMLElement>("parent");
2222
2323
dragAndDrop({
2424
parent,

0 commit comments

Comments
 (0)