mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 16:16:41 +08:00
fix(datetime): update active day styling when day is selected (#24454)
Resolves #24414, #24451
This commit is contained in:
@ -273,6 +273,11 @@ export class Datetime implements ComponentInterface {
|
||||
this.parsedMinuteValues = convertToArrayOfNumbers(this.minuteValues);
|
||||
}
|
||||
|
||||
@Watch('activeParts')
|
||||
protected activePartsChanged() {
|
||||
this.activePartsClone = this.activeParts;
|
||||
}
|
||||
|
||||
/**
|
||||
* The locale to use for `ion-datetime`. This
|
||||
* impacts month and day name formatting.
|
||||
@ -944,7 +949,7 @@ export class Datetime implements ComponentInterface {
|
||||
ampm: hour >= 12 ? 'pm' : 'am'
|
||||
}
|
||||
|
||||
this.activePartsClone = this.activeParts = {
|
||||
this.activeParts = {
|
||||
month,
|
||||
day,
|
||||
year,
|
||||
@ -1206,7 +1211,7 @@ export class Datetime implements ComponentInterface {
|
||||
month,
|
||||
day,
|
||||
year
|
||||
})
|
||||
});
|
||||
}}
|
||||
>{day}</button>
|
||||
)
|
||||
|
||||
@ -79,3 +79,25 @@ describe('Footer', () => {
|
||||
});
|
||||
|
||||
|
||||
describe('datetime: selecting a day', () => {
|
||||
|
||||
it('should update the active day', async () => {
|
||||
const page = await newE2EPage({
|
||||
html: `
|
||||
<ion-datetime show-default-buttons="true" value="2021-12-25T12:40:00.000Z"></ion-datetime>
|
||||
`
|
||||
});
|
||||
|
||||
const activeDay = await page.find('ion-datetime >>> .calendar-day-active');
|
||||
|
||||
expect(activeDay.innerText).toEqual('25');
|
||||
|
||||
const dayBtn = await page.find('ion-datetime >>> .calendar-day[data-day="13"][data-month="12"]');
|
||||
dayBtn.click();
|
||||
await page.waitForChanges();
|
||||
|
||||
const newActiveDay = await page.find('ion-datetime >>> .calendar-day-active');
|
||||
|
||||
expect(newActiveDay.innerText).toEqual('13');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user