Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(form:widget:date): fix format default value #833

Merged
merged 2 commits into from Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/form/src/widgets/date/date.widget.spec.ts
Expand Up @@ -69,7 +69,6 @@ describe('form: widget: date', () => {
};
page.newSchema(s).checkValue('a', null).setValue('a', new Date(2019, 0, 1)).dc(1);
flush();
expect(page.getValue('a') instanceof Date).toBe(true);
const ipt = page.getEl('.ant-picker-input input') as HTMLInputElement;
expect(ipt.value).toContain(`2019-01-01`);
}));
Expand Down
4 changes: 3 additions & 1 deletion packages/form/src/widgets/date/date.widget.ts
Expand Up @@ -63,6 +63,8 @@ export class DateWidget extends ControlUIWidget<SFDateWidgetSchema> implements O
this.displayValue = value;
}
this.detectChanges();
// TODO: Need to wait for the rendering to complete, otherwise it will be overwritten of end widget
setTimeout(() => this._change(this.displayValue));
}

_change(value: Date | Date[] | null) {
Expand All @@ -77,8 +79,8 @@ export class DateWidget extends ControlUIWidget<SFDateWidgetSchema> implements O
: format(value, this.startFormat);

if (this.flatRange) {
this.setEnd(res[1]);
this.setValue(res[0]);
this.setEnd(res[1]);
} else {
this.setValue(res);
}
Expand Down