Skip to content

Commit

Permalink
fix: ensure fields appear on mount
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Feb 22, 2025
1 parent 2065079 commit d0e108d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 5 additions & 5 deletions packages/devtools/src/init.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, getCurrentInstance, nextTick, onUnmounted, watch } from 'vue';
import { App, getCurrentInstance, nextTick, onMounted, onUnmounted, watch } from 'vue';
import { throttle } from 'packages/shared/src';
import { FormField, FormReturns } from '@core/index';
import { isSSR } from '@core/utils/common';
Expand Down Expand Up @@ -166,9 +166,9 @@ export function registerField(field: FormField<any>, type: string) {
deep: true,
});

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

refreshInspector();
}

export function registerForm(form: FormReturns) {
Expand All @@ -179,7 +179,7 @@ export function registerForm(form: FormReturns) {
deep: true,
});

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

refreshInspector();
}
14 changes: 11 additions & 3 deletions packages/playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import RadioItem from '@/components/RadioItem.vue';
import Switch from '@/components/Switch.vue';
import InputTextArea from '@/components/InputTextArea.vue';
import AllForm from './components/AllForm.vue';
import { ref } from 'vue';
const min = new Date(2025, 0, 4, 0, 0, 0, 0);
const value = new Date('2025-01-15');
Expand All @@ -21,6 +22,8 @@ const options = [
{ label: 'Option 2', value: '2' },
{ label: 'Option 3', value: '3' },
];
const isNotificationsEnabled = ref(false);
</script>

<template>
Expand All @@ -44,10 +47,15 @@ const options = [
<RadioItem name="gender" value="other" label="Other" />
</RadioGroup>

<Switch name="notifications" label="Enable notifications" />
<Switch name="notifications" label="Enable notifications" v-model="isNotificationsEnabled" />

<Calendar name="calendar" label="Calendar" />
<InputText
v-if="isNotificationsEnabled"
name="notificationName"
label="Notification name"
placeholder="Enter notification name"
/>

<AllForm />
<!-- <AllForm /> -->
</div>
</template>

0 comments on commit d0e108d

Please sign in to comment.