Skip to content

Commit 784f2e4

Browse files
committed
fix(date-range): Update date time input manually when locale changes. Some tweaks.
1 parent 7530579 commit 784f2e4

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

projects/igniteui-angular/src/lib/date-range-picker/date-range-picker-inputs.common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ export class DateRangePickerFormatPipe implements PipeTransform {
4747
if (!isDate(end)) {
4848
end = DateTimeUtil.parseIsoDate(end);
4949
}
50-
const startDate = appliedFormat ? this.i18nFormatter.formatDate(start, appliedFormat, locale || 'en') : start?.toLocaleDateString();
51-
const endDate = appliedFormat ? this.i18nFormatter.formatDate(end, appliedFormat, locale || 'en') : end?.toLocaleDateString();
50+
const startDate = this.i18nFormatter.formatDate(start, appliedFormat, locale);
51+
const endDate = this.i18nFormatter.formatDate(end, appliedFormat, locale);
5252
let formatted;
5353
if (start) {
5454
formatted = `${startDate} - `;

projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<!-- only set mask placeholder when empty, otherwise input group might use it as label if none is set -->
3131
<input #singleInput igxInput type="text" [igxReadOnlyInput]="readOnly" readonly [disabled]="disabled" [placeholder]="value ? '' : singleInputFormat"
3232
role="combobox" aria-haspopup="grid" [attr.aria-expanded]="!collapsed" [attr.aria-labelledby]="label?.id"
33-
[value]="value | dateRange: displayFormat : locale : formatter" />
33+
[value]="value | dateRange: appliedFormat : locale : formatter" />
3434

3535
@if (!toggleComponents.length) {
3636
<igx-prefix (click)="toggle()">

projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,12 +1286,13 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective
12861286
this.projectedInputs.forEach(i => {
12871287
const input = i as IgxDateRangeInputsBaseComponent;
12881288
input.dateTimeEditor.locale = this.locale;
1289+
input.dateTimeEditor.updateMask();
12891290
});
12901291
}
12911292

12921293
protected override onResourceChange(args: CustomEvent<IResourceChangeEventArgs>) {
12931294
super.onResourceChange(args);
1294-
if (this.hasProjectedInputs) {
1295+
if (args.detail.oldLocale !== args.detail.newLocale && this.hasProjectedInputs) {
12951296
this.updateInputLocale();
12961297
this.updateDisplayFormat();
12971298
}

projects/igniteui-angular/src/lib/directives/date-time-editor/date-time-editor.directive.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,11 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
304304
maskParser: MaskParsingService,
305305
platform: PlatformUtil,
306306
@Inject(DOCUMENT) private _document: any,
307-
@Inject(LOCALE_ID) private _locale: any,
307+
@Inject(LOCALE_ID) private _localeID: any,
308308
@Inject(I18N_FORMATTER) private _i18nFormatter: BaseFormatter) {
309309
super(elementRef, maskParser, renderer, platform);
310310
this.document = this._document as Document;
311-
this.locale = this.locale || this._locale;
311+
this.locale = this.locale || this._localeID;
312312
}
313313

314314
@HostListener('wheel', ['$event'])
@@ -533,7 +533,8 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
533533
this.setMask(this.inputFormat);
534534
}
535535

536-
private updateMask(): void {
536+
/** @hidden @internal */
537+
public updateMask(): void {
537538
if (this._focused) {
538539
// store the cursor position as it will be moved during masking
539540
const cursor = this.selectionEnd;

0 commit comments

Comments
 (0)