Skip to content

Fix: DefaultTime input is ignored and not working #396

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions projects/datetime-picker/src/lib/datepicker-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ export class NgxMatDatepickerContent<S, D = NgxExtractDateTypeFromSelection<S>>
// pressing escape), whereas when selecting a single value it means that the value didn't
// change. This isn't very intuitive, but it's here for backwards-compatibility.
if (isRange && this._rangeSelectionStrategy) {
// Set default time if there is no date set and defined
if (this.datepicker._defaultTime && 3 == this.datepicker._defaultTime.length )
{
const sel = selection as NgxDateRange<D>;
if (null == sel.start || (sel.start && sel.end)) {
this._dateAdapter.setTimeByDefaultValues(value, this.datepicker._defaultTime);
}
}


const newSelection = this._rangeSelectionStrategy.selectionFinished(
value,
selection as unknown as NgxDateRange<D>,
Expand All @@ -257,6 +267,11 @@ export class NgxMatDatepickerContent<S, D = NgxExtractDateTypeFromSelection<S>>
if (value &&
(isRange || !isSame)
) {
// There ist no date set until now, so set default time if defined
if (null == this._model.selection && this.datepicker._defaultTime && 3 == this.datepicker._defaultTime.length ) {
this._dateAdapter.setTimeByDefaultValues(value, this.datepicker._defaultTime);
}

this._model.add(value);
}
}
Expand Down