Skip to content

Commit

Permalink
fix(form:date): fix invalid default value in flat mode (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Oct 1, 2018
1 parent 4121b90 commit d2c89ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/form/src/widgets/date/date.widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class DateWidget extends ControlWidget implements OnInit {

reset(value: any) {
if (this.flatRange) {
this.displayValue = [value, this.endProperty.formData];
this.displayValue = value == null ? [] : [value, this.endProperty.formData];
} else {
this.displayValue = value;
}
Expand All @@ -148,7 +148,7 @@ export class DateWidget extends ControlWidget implements OnInit {
? value.map(d => format(d, this.format))
: format(value, this.format);

if (Array.isArray(res)) {
if (this.flatRange) {
this.setEnd(res[1]);
this.setValue(res[0]);
} else {
Expand Down
4 changes: 4 additions & 0 deletions packages/form/src/widgets/date/demo/simple.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export class DemoComponent {
type: 'string',
ui: { widget: 'date', end: 'end' },
},
end: {
type: 'string',
ui: { widget: 'date', end: 'end' },
},
},
};

Expand Down

0 comments on commit d2c89ca

Please sign in to comment.