Commit 38f5072695f63b30c6ce6b2741b003db605abd82
1 parent
b92b8a3c
fix(form): remove field binding when deleting schema #471
Showing
5 changed files
with
8 additions
and
12 deletions
CHANGELOG.zh_CN.md
build/vite/plugin/index.ts
... | ... | @@ -16,7 +16,7 @@ import { configThemePlugin } from './theme'; |
16 | 16 | import { configImageminPlugin } from './imagemin'; |
17 | 17 | import { configWindiCssPlugin } from './windicss'; |
18 | 18 | import { configSvgIconsPlugin } from './svgSprite'; |
19 | -// import { configHmrPlugin } from './hmr'; | |
19 | +import { configHmrPlugin } from './hmr'; | |
20 | 20 | |
21 | 21 | export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { |
22 | 22 | const { |
... | ... | @@ -35,7 +35,7 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { |
35 | 35 | ]; |
36 | 36 | |
37 | 37 | // TODO |
38 | - // !isBuild && vitePlugins.push(configHmrPlugin()); | |
38 | + !isBuild && vitePlugins.push(configHmrPlugin()); | |
39 | 39 | |
40 | 40 | // @vitejs/plugin-legacy |
41 | 41 | VITE_LEGACY && isBuild && vitePlugins.push(legacy()); | ... | ... |
src/components/Form/src/hooks/useForm.ts
... | ... | @@ -77,8 +77,7 @@ export function useForm(props?: Props): UseFormReturnType { |
77 | 77 | }, |
78 | 78 | |
79 | 79 | removeSchemaByFiled: async (field: string | string[]) => { |
80 | - const form = await getForm(); | |
81 | - form.removeSchemaByFiled(field); | |
80 | + unref(formRef)?.removeSchemaByFiled(field); | |
82 | 81 | }, |
83 | 82 | |
84 | 83 | // TODO promisify | ... | ... |
src/components/Form/src/hooks/useFormEvents.ts
... | ... | @@ -88,7 +88,9 @@ export function useFormEvents({ |
88 | 88 | */ |
89 | 89 | async function removeSchemaByFiled(fields: string | string[]): Promise<void> { |
90 | 90 | const schemaList: FormSchema[] = cloneDeep(unref(getSchema)); |
91 | - if (!fields) return; | |
91 | + if (!fields) { | |
92 | + return; | |
93 | + } | |
92 | 94 | |
93 | 95 | let fieldList: string[] = isString(fields) ? [fields] : fields; |
94 | 96 | if (isString(fields)) { |
... | ... | @@ -107,6 +109,7 @@ export function useFormEvents({ |
107 | 109 | if (isString(field)) { |
108 | 110 | const index = schemaList.findIndex((schema) => schema.field === field); |
109 | 111 | if (index !== -1) { |
112 | + delete formModel[field]; | |
110 | 113 | schemaList.splice(index, 1); |
111 | 114 | } |
112 | 115 | } | ... | ... |