From 505fe3ea342e4da93da33086f15875abf9dc5818 Mon Sep 17 00:00:00 2001 From: Alena Popova <52053630+alyonagerasimova@users.noreply.github.com> Date: Fri, 7 Jun 2024 18:04:38 +0400 Subject: [PATCH] fix(kit): `InputDateTime` should format textfield value on blur (#7659) Co-authored-by: alen.a.popova --- .../tests/kit/input-date-time/input-date-time.spec.ts | 9 +++++++++ .../input-date-time/input-date-time.component.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/projects/demo-playwright/tests/kit/input-date-time/input-date-time.spec.ts b/projects/demo-playwright/tests/kit/input-date-time/input-date-time.spec.ts index 9c9ffbed52f6..606277db162b 100644 --- a/projects/demo-playwright/tests/kit/input-date-time/input-date-time.spec.ts +++ b/projects/demo-playwright/tests/kit/input-date-time/input-date-time.spec.ts @@ -149,6 +149,15 @@ describe('InputDateTime', () => { '15.11.2018, '.length, ); }); + + test('should time to pre-fill with zeros on blur', async ({page}) => { + await tuiGoto(page, '/components/input-date-time/API?timeMode=HH:MM:SS.MSS'); + + await inputDateTime.textfield.fill('07.06.2024, 23:59'); + await inputDateTime.textfield.blur(); + + await expect(inputDateTime.textfield).toHaveValue('07.06.2024, 23:59:00.000'); + }); }); describe('invalid date', () => { diff --git a/projects/kit/components/input-date-time/input-date-time.component.ts b/projects/kit/components/input-date-time/input-date-time.component.ts index 3d0667c3f9ce..54fffeb2eb25 100644 --- a/projects/kit/components/input-date-time/input-date-time.component.ts +++ b/projects/kit/components/input-date-time/input-date-time.component.ts @@ -312,7 +312,7 @@ export class TuiInputDateTimeComponent if ( this.value[0] === null || this.value[1] !== null || - this.nativeValue.length <= this.fillerLength + DATE_TIME_SEPARATOR.length || + this.nativeValue.length === this.fillerLength || this.timeMode === 'HH:MM' ) { return;