mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 23:58:13 +08:00
chore(): sync
This commit is contained in:
@ -257,9 +257,11 @@
|
||||
|
||||
/**
|
||||
* Day that is selected and is today
|
||||
* should have white color.
|
||||
* should have base background color
|
||||
* with contrast text.
|
||||
*/
|
||||
:host .calendar-day.calendar-day-today.calendar-day-active {
|
||||
background: current-color(base);
|
||||
color: current-color(contrast);
|
||||
}
|
||||
|
||||
|
||||
@ -340,6 +340,9 @@ export class Datetime implements ComponentInterface {
|
||||
* dates are selected. Only used if there are 0 or more than 1
|
||||
* selected (i.e. unused for exactly 1). By default, the header
|
||||
* text is set to "numberOfDates days".
|
||||
*
|
||||
* See https://ionicframework.com/docs/troubleshooting/runtime#accessing-this
|
||||
* if you need to access `this` from within the callback.
|
||||
*/
|
||||
@Prop() titleSelectedDatesFormatter?: TitleSelectedDatesFormatter;
|
||||
|
||||
@ -1280,21 +1283,42 @@ export class Datetime implements ComponentInterface {
|
||||
(month !== undefined && month !== workingParts.month) || (year !== undefined && year !== workingParts.year);
|
||||
const bodyIsVisible = el.classList.contains('datetime-ready');
|
||||
const { isGridStyle, showMonthAndYear } = this;
|
||||
if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
|
||||
this.animateToDate(targetValue);
|
||||
} else {
|
||||
/**
|
||||
* We only need to do this if we didn't just animate to a new month,
|
||||
* since that calls prevMonth/nextMonth which calls setWorkingParts for us.
|
||||
*/
|
||||
this.setWorkingParts({
|
||||
month,
|
||||
day,
|
||||
year,
|
||||
hour,
|
||||
minute,
|
||||
ampm,
|
||||
});
|
||||
|
||||
let areAllSelectedDatesInSameMonth = true;
|
||||
if (Array.isArray(valueToProcess)) {
|
||||
const firstMonth = valueToProcess[0].month;
|
||||
for (const date of valueToProcess) {
|
||||
if (date.month !== firstMonth) {
|
||||
areAllSelectedDatesInSameMonth = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If there is more than one date selected
|
||||
* and the dates aren't all in the same month,
|
||||
* then we should neither animate to the date
|
||||
* nor update the working parts because we do
|
||||
* not know which date the user wants to view.
|
||||
*/
|
||||
if (areAllSelectedDatesInSameMonth) {
|
||||
if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
|
||||
this.animateToDate(targetValue);
|
||||
} else {
|
||||
/**
|
||||
* We only need to do this if we didn't just animate to a new month,
|
||||
* since that calls prevMonth/nextMonth which calls setWorkingParts for us.
|
||||
*/
|
||||
this.setWorkingParts({
|
||||
month,
|
||||
day,
|
||||
year,
|
||||
hour,
|
||||
minute,
|
||||
ampm,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -458,6 +458,44 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
|
||||
});
|
||||
});
|
||||
|
||||
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
|
||||
test.describe(title('datetime: today button rendering'), () => {
|
||||
test('should render today button correctly when selected', async ({ page }) => {
|
||||
test.info().annotations.push({
|
||||
type: 'issue',
|
||||
description: 'FW-5808',
|
||||
});
|
||||
await page.setContent(
|
||||
`
|
||||
<ion-datetime presentation="date" value="2022-01-02"></ion-datetime>
|
||||
|
||||
<script>
|
||||
const mockToday = '2022-01-02T16:22';
|
||||
Date = class extends Date {
|
||||
constructor(...args) {
|
||||
if (args.length === 0) {
|
||||
super(mockToday)
|
||||
} else {
|
||||
super(...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const datetime = page.locator('ion-datetime');
|
||||
|
||||
await page.waitForSelector('.datetime-ready');
|
||||
|
||||
await expect(datetime.locator('.calendar-day-today')).toHaveScreenshot(
|
||||
screenshot(`datetime-today-calendar-button`)
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* The calendar day highlight does not render
|
||||
* on iOS and has the same behavior across directions.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 973 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 976 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@ -5,7 +5,7 @@ import { configs, test } from '@utils/test/playwright';
|
||||
|
||||
const SINGLE_DATE = '2022-06-01';
|
||||
const MULTIPLE_DATES = ['2022-06-01', '2022-06-02', '2022-06-03'];
|
||||
const MULTIPLE_DATES_SEPARATE_MONTHS = ['2022-04-01', '2022-05-01', '2022-06-01'];
|
||||
const MULTIPLE_DATES_SEPARATE_MONTHS = ['2022-03-01', '2022-04-01', '2022-05-01'];
|
||||
|
||||
interface DatetimeMultipleConfig {
|
||||
multiple?: boolean;
|
||||
@ -158,10 +158,32 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
|
||||
});
|
||||
});
|
||||
|
||||
test('multiple default values across months should display at least one value', async () => {
|
||||
test('should scroll to new month when value is updated with multiple dates in the same month', async ({ page }) => {
|
||||
test.info().annotations.push({
|
||||
type: 'issue',
|
||||
description: 'https://github.com/ionic-team/ionic-framework/issues/28602',
|
||||
});
|
||||
const datetime = await datetimeFixture.goto(config, MULTIPLE_DATES_SEPARATE_MONTHS);
|
||||
await datetime.evaluate((el: HTMLIonDatetimeElement, dates: string[]) => {
|
||||
el.value = dates;
|
||||
}, MULTIPLE_DATES);
|
||||
|
||||
await page.waitForChanges();
|
||||
|
||||
const monthYear = datetime.locator('.calendar-month-year');
|
||||
await expect(monthYear).toHaveText(/April 2022/);
|
||||
await expect(monthYear).toHaveText(/June 2022/);
|
||||
});
|
||||
|
||||
test('should not scroll to new month when value is updated with dates in different months', async ({ page }) => {
|
||||
const datetime = await datetimeFixture.goto(config, MULTIPLE_DATES);
|
||||
await datetime.evaluate((el: HTMLIonDatetimeElement, dates: string[]) => {
|
||||
el.value = dates;
|
||||
}, MULTIPLE_DATES_SEPARATE_MONTHS);
|
||||
|
||||
await page.waitForChanges();
|
||||
|
||||
const monthYear = datetime.locator('.calendar-month-year');
|
||||
await expect(monthYear).toHaveText(/June 2022/);
|
||||
});
|
||||
|
||||
test('with buttons, should only update value when confirm is called', async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user