SIGN IN SIGN UP

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

0 0 0 TypeScript

fix(datetime): display today's date and time when value is an empty string (#29839)

Issue number: resolves #29669

---------

## What is the current behavior?

Setting `value` to an empty string on `<ion-datetime>` renders a May
2021 calendar:

```html
<ion-datetime value=""></ion-datetime>
```

## What is the new behavior?

Show the month and time for today's date when value is an empty string.
This matches how a native `input` with `type="datetime-local"` works.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

## Other information

This can be tested by removing my fix in `datetime.tsx` and running the
e2e test for Datetime:

```bash
npm run test.e2e src/components/datetime/test/basic/datetime.e2e.ts
```

The `should display today's date and time when value is an empty string`
test should fail.

Alternatively, you can add a datetime with `value=""` and see the
calendar before & after my fix.

---------

Co-authored-by: Tanner Reits <47483144+tanner-reits@users.noreply.github.com>
B
Brandy Carney committed
f1d50c0f645b3adf51426c24a1da0bbd1223f1d5
Parent: ac3959a
Committed by GitHub <noreply@github.com> on 9/6/2024, 4:28:33 PM