mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
fix(datetime): ionChange is no longer called for out of range dates (#23940)
resolves #23939
This commit is contained in:
@ -1091,6 +1091,17 @@ export class Datetime implements ComponentInterface {
|
|||||||
const activeElement = this.el!.shadowRoot!.elementFromPoint(x, y)!;
|
const activeElement = this.el!.shadowRoot!.elementFromPoint(x, y)!;
|
||||||
const value = parseInt(activeElement.getAttribute('data-value')!, 10);
|
const value = parseInt(activeElement.getAttribute('data-value')!, 10);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When scrolling to a month that is out of
|
||||||
|
* bounds, the hour/minute column values may
|
||||||
|
* be updated, triggering a scroll callback.
|
||||||
|
* Check to make sure there is a valid
|
||||||
|
* hour/minute element so we do not emit NaN.
|
||||||
|
*/
|
||||||
|
if (Number.isNaN(value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (colType === 'hour') {
|
if (colType === 'hour') {
|
||||||
this.setWorkingParts({
|
this.setWorkingParts({
|
||||||
...this.workingParts,
|
...this.workingParts,
|
||||||
|
|||||||
@ -44,9 +44,8 @@
|
|||||||
<h2>Value inside Bounds</h2>
|
<h2>Value inside Bounds</h2>
|
||||||
<ion-datetime
|
<ion-datetime
|
||||||
id="inside"
|
id="inside"
|
||||||
min="2021-06-05"
|
min="2021-09"
|
||||||
max="2021-06-29"
|
max="2021-10"
|
||||||
value="2021-06-20"
|
|
||||||
></ion-datetime>
|
></ion-datetime>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid-item">
|
<div class="grid-item">
|
||||||
@ -60,6 +59,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const datetime = document.querySelector('ion-datetime');
|
||||||
|
datetime.addEventListener('ionChange', (ev) => {
|
||||||
|
console.log('Change', ev.detail.value);
|
||||||
|
})
|
||||||
|
</script>
|
||||||
</ion-app>
|
</ion-app>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user