diff --git a/core/src/components/datetime/datetime.tsx b/core/src/components/datetime/datetime.tsx index 5be7040e7e..9154c24e60 100644 --- a/core/src/components/datetime/datetime.tsx +++ b/core/src/components/datetime/datetime.tsx @@ -1234,7 +1234,8 @@ export class Datetime implements ComponentInterface { } private processValue = (value?: string | string[] | null) => { - const hasValue = value !== null && value !== undefined && (!Array.isArray(value) || value.length > 0); + const hasValue = + value !== null && value !== undefined && value !== '' && (!Array.isArray(value) || value.length > 0); const valueToProcess = hasValue ? parseDate(value) : this.defaultParts; const { minParts, maxParts, workingParts, el } = this; diff --git a/core/src/components/datetime/test/basic/datetime.e2e.ts b/core/src/components/datetime/test/basic/datetime.e2e.ts index eb025b41bc..f96cc64bea 100644 --- a/core/src/components/datetime/test/basic/datetime.e2e.ts +++ b/core/src/components/datetime/test/basic/datetime.e2e.ts @@ -121,6 +121,38 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => await expect(datetime).toHaveJSProperty('value', '2022-10-01T16:22:00'); }); + + test("should display today's date and time when value is an empty string", async ({ page }) => { + await page.setContent( + ` + + + + `, + config + ); + + await page.locator('.datetime-ready').waitFor(); + + // July 24, 2024 + const todayButton = page.locator('.calendar-day[data-day="24"][data-month="7"][data-year="2024"]'); + await expect(todayButton).toHaveClass(/calendar-day-today/); + + // 4:22 PM + const timeBody = page.locator('ion-datetime .time-body'); + await expect(timeBody).toHaveText('4:22 PM'); + }); }); });