Skip to content

Commit

Permalink
fix: only register fields on mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Feb 22, 2025
1 parent a6153e9 commit c3a8842
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
28 changes: 16 additions & 12 deletions packages/devtools/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,27 +159,31 @@ export function initDevTools() {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function registerField(field: FormField<any>, type: string) {
const vm = initDevTools();
const watchable = _registerField(field, type, vm);
onMounted(() => {
const vm = initDevTools();
const watchable = _registerField(field, type, vm);

watch(watchable, refreshInspector, {
deep: true,
watch(watchable, refreshInspector, {
deep: true,
});

setTimeout(refreshInspector, 500);
});

// TODO: Figure out why this is needed
onMounted(() => setTimeout(refreshInspector, 500));
onUnmounted(refreshInspector);
}

export function registerForm(form: FormReturns) {
const vm = initDevTools();
const watchable = _registerForm(form, vm);
onMounted(() => {
const vm = initDevTools();
const watchable = _registerForm(form, vm);

watch(watchable, refreshInspector, {
deep: true,
});

watch(watchable, refreshInspector, {
deep: true,
setTimeout(refreshInspector, 500);
});

// TODO: Figure out why this is needed
onMounted(() => setTimeout(refreshInspector, 500));
onUnmounted(refreshInspector);
}
1 change: 1 addition & 0 deletions packages/playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import RadioItem from '@/components/RadioItem.vue';
import Switch from '@/components/Switch.vue';
import InputTextArea from '@/components/InputTextArea.vue';
import { ref } from 'vue';
import AllForm from './components/AllForm.vue';
const min = new Date(2025, 0, 4, 0, 0, 0, 0);
const value = new Date('2025-01-15');
Expand Down

0 comments on commit c3a8842

Please sign in to comment.