diff --git a/packages/amis-core/src/renderers/wrapControl.tsx b/packages/amis-core/src/renderers/wrapControl.tsx
index aafddc21f..a8c24e22c 100644
--- a/packages/amis-core/src/renderers/wrapControl.tsx
+++ b/packages/amis-core/src/renderers/wrapControl.tsx
@@ -367,10 +367,7 @@ export function wrapControl<
} else if (model) {
const valueByName = getVariable(props.data, model.name);
- if (
- valueByName !== undefined &&
- isEqual(props.defaultValue, prevProps.defaultValue)
- ) {
+ if (isEqual(props.defaultValue, prevProps.defaultValue)) {
// value 非公式表达式时,name 值优先,若 defaultValue 主动变动时,则使用 defaultValue
if (
// 然后才是查看关联的 name 属性值是否变化
diff --git a/packages/amis/__tests__/renderers/Form/__snapshots__/index.test.tsx.snap b/packages/amis/__tests__/renderers/Form/__snapshots__/index.test.tsx.snap
index 9c1892735..275c675e8 100644
--- a/packages/amis/__tests__/renderers/Form/__snapshots__/index.test.tsx.snap
+++ b/packages/amis/__tests__/renderers/Form/__snapshots__/index.test.tsx.snap
@@ -322,6 +322,177 @@ exports[`Renderer:Form initApi 1`] = `
`;
+exports[`Renderer:Form reset 1`] = `
+
+`;
+
exports[`Renderer:Form sendOn:true 1`] = `
{
expect(fetcher).toHaveBeenCalled();
expect(container).toMatchSnapshot();
});
+
+test('Renderer:Form reset', async () => {
+ const pristineData = {
+ email: 'user@baidu.com'
+ };
+ const onReset = jest.fn();
+ const {container, getByText} = render(
+ amisRender(
+ {
+ type: 'form',
+ body: [
+ {
+ type: 'input-text',
+ name: 'name',
+ label: '姓名'
+ },
+ {
+ type: 'input-email',
+ name: 'email',
+ label: '邮箱',
+ value: pristineData.email
+ }
+ ],
+ actions: [
+ {
+ type: 'reset',
+ label: 'ResetButton'
+ },
+ {
+ type: 'submit',
+ label: 'SubmitBtn'
+ }
+ ]
+ },
+ {onReset},
+ makeEnv({})
+ )
+ );
+ const textInput = container.querySelector(
+ 'input[name="name"]'
+ ) as HTMLInputElement;
+ const emailInput = container.querySelector(
+ 'input[name="email"]'
+ ) as HTMLInputElement;
+
+ expect(textInput).toBeInTheDocument();
+ expect(emailInput).toBeInTheDocument();
+
+ fireEvent.change(textInput, {target: {value: 'username'}});
+ fireEvent.change(emailInput, {target: {value: 'user_changed@baidu.com'}});
+ fireEvent.click(getByText('ResetButton'));
+
+ await waitFor(() => {
+ expect(onReset).toHaveBeenCalled();
+ expect(onReset).toHaveBeenCalledWith(pristineData);
+ });
+
+ expect(container).toMatchSnapshot();
+});