Skip to content

Commit

Permalink
chore: fix native date reset (#3810)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Mar 6, 2023
1 parent 67747fc commit 8f9969f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion projects/kit/components/input-date/input-date.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class TuiInputDateComponent
}

get computedMobile(): boolean {
return this.isMobile && (!!this.mobileCalendar || this.options.nativePicker);
return this.isMobile && (!!this.mobileCalendar || this.nativePicker);
}

get nativePicker(): boolean {
Expand Down
4 changes: 4 additions & 0 deletions projects/kit/components/input-date/input-date.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export class TuiInputDateDirective extends AbstractTuiTextfieldHost<TuiInputDate
}

onValueChange(value: string): void {
if (!value) {
this.host.nativeValue = '';
}

this.host.onValueChange(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {TUI_TEXTFIELD_HOST, TuiTextfieldHost} from '@taiga-ui/core';
template: '',
host: {
type: 'date',
'[tabIndex]': 'host.focusable ? 0 : -1',
'[tabIndex]': '-1',
'[value]': 'value',
'(change)': 'onChange($event.target.value)',
'(click.stop.silent)': '0',
Expand All @@ -31,7 +31,7 @@ export class TuiNativeDateComponent {

onChange(value: string): void {
this.host.onValueChange(
TuiDay.normalizeParse(value, 'YMD').toString(this.dateFormat),
value ? TuiDay.normalizeParse(value, 'YMD').toString(this.dateFormat) : '',
);
}
}

0 comments on commit 8f9969f

Please sign in to comment.