fix(datetime): support typing time values in a 24-hour format (#30147)

- Adjusted the `selectMultiColumn` logic to handle keyboard values like
20 and 22 dynamically.
- Introduced checks for the maximum column value to enable flexible
input behavior.
- Added e2e tests to verify correct value selection for both 12-hour and
24-hour formats.

Issue number: resolves #28877

---------

## What is the current behavior?

In the ion-datetime component, when typing 2000 in the keyboard the
resulted time value is 02:00 (in 24-hour format)

Examples:
https://forum.ionicframework.com/t/ion-datetime-disable-opening-keyboard/224558/6?u=dennisskylegs

## What is the new behavior?
In the ion-datetime component, when typing 2000 in the keyboard the
resulted time value is 20:00 (in 24-hour format)

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

---------

Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
Co-authored-by: ShaneK <shane@shanessite.net>
This commit is contained in:
Victoria Unizhona
2025-03-26 21:06:04 +02:00
committed by GitHub
parent 1cfa915e8f
commit ac6e6a0317
3 changed files with 234 additions and 87 deletions

View File

@ -1984,7 +1984,7 @@ export class Datetime implements ComponentInterface {
});
this.setActiveParts({
...activePart,
...this.getActivePartsWithFallback(),
hour: ev.detail.value,
});
@ -2024,7 +2024,7 @@ export class Datetime implements ComponentInterface {
});
this.setActiveParts({
...activePart,
...this.getActivePartsWithFallback(),
minute: ev.detail.value,
});
@ -2070,7 +2070,7 @@ export class Datetime implements ComponentInterface {
});
this.setActiveParts({
...activePart,
...this.getActivePartsWithFallback(),
ampm: ev.detail.value,
hour,
});