Skip to content

Commit

Permalink
fix(form): remove field binding when deleting schema #471
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Apr 19, 2021
1 parent b92b8a3 commit 38f5072
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

- 修复黑暗主题刷新闪烁的白屏
- 修复标签页关闭其他功能失效问题
- 修复表单已知问题

## 2.3.0 (2021-04-10)

Expand Down
4 changes: 2 additions & 2 deletions build/vite/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { configThemePlugin } from './theme';
import { configImageminPlugin } from './imagemin';
import { configWindiCssPlugin } from './windicss';
import { configSvgIconsPlugin } from './svgSprite';
// import { configHmrPlugin } from './hmr';
import { configHmrPlugin } from './hmr';

export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
const {
Expand All @@ -35,7 +35,7 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
];

// TODO
// !isBuild && vitePlugins.push(configHmrPlugin());
!isBuild && vitePlugins.push(configHmrPlugin());

// @vitejs/plugin-legacy
VITE_LEGACY && isBuild && vitePlugins.push(legacy());
Expand Down
3 changes: 1 addition & 2 deletions src/components/Form/src/hooks/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ export function useForm(props?: Props): UseFormReturnType {
},

removeSchemaByFiled: async (field: string | string[]) => {
const form = await getForm();
form.removeSchemaByFiled(field);
unref(formRef)?.removeSchemaByFiled(field);
},

// TODO promisify
Expand Down
5 changes: 4 additions & 1 deletion src/components/Form/src/hooks/useFormEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ export function useFormEvents({
*/
async function removeSchemaByFiled(fields: string | string[]): Promise<void> {
const schemaList: FormSchema[] = cloneDeep(unref(getSchema));
if (!fields) return;
if (!fields) {
return;
}

let fieldList: string[] = isString(fields) ? [fields] : fields;
if (isString(fields)) {
Expand All @@ -107,6 +109,7 @@ export function useFormEvents({
if (isString(field)) {
const index = schemaList.findIndex((schema) => schema.field === field);
if (index !== -1) {
delete formModel[field];
schemaList.splice(index, 1);
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/components/Icon/README.md

This file was deleted.

0 comments on commit 38f5072

Please sign in to comment.