Skip to content

Commit 2f99aea

Browse files
fix(datetime): selected today button renders correctly on ios (#28740)
Issue number: Internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> We removed the background color from today's calendar day button if selected when implementing the calendar-day button shadow part feature: 79b005d#diff-8e2912d52559aa44c9c6dc062c8d683e7b51c92c7b7ba420ad6f7587f1e1a61aL139 We did not catch this because we do not have test coverage for this use case. We typically avoid rendering datetime on today's date because "today" could be something totally different depending on the test machine's locale/configuration. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Adds the background rule that was removed - Added test coverage. I mocked today's date to be a fixed date so it never changes ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> --------- Co-authored-by: ionitron <[email protected]>
1 parent 4cf948f commit 2f99aea

8 files changed

+41
-1
lines changed

core/src/components/datetime/datetime.ios.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,11 @@
249249

250250
/**
251251
* Day that is selected and is today
252-
* should have white color.
252+
* should have base background color
253+
* with contrast text.
253254
*/
254255
:host .calendar-day.calendar-day-today.calendar-day-active {
256+
background: current-color(base);
255257
color: current-color(contrast);
256258
}
257259

core/src/components/datetime/test/basic/datetime.e2e.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,44 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
458458
});
459459
});
460460

461+
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
462+
test.describe(title('datetime: today button rendering'), () => {
463+
test('should render today button correctly when selected', async ({ page }) => {
464+
test.info().annotations.push({
465+
type: 'issue',
466+
description: 'FW-5808',
467+
});
468+
await page.setContent(
469+
`
470+
<ion-datetime presentation="date" value="2022-01-02"></ion-datetime>
471+
472+
<script>
473+
const mockToday = '2022-01-02T16:22';
474+
Date = class extends Date {
475+
constructor(...args) {
476+
if (args.length === 0) {
477+
super(mockToday)
478+
} else {
479+
super(...args);
480+
}
481+
}
482+
}
483+
</script>
484+
`,
485+
config
486+
);
487+
488+
const datetime = page.locator('ion-datetime');
489+
490+
await page.waitForSelector('.datetime-ready');
491+
492+
await expect(datetime.locator('.calendar-day-today')).toHaveScreenshot(
493+
screenshot(`datetime-today-calendar-button`)
494+
);
495+
});
496+
});
497+
});
498+
461499
/**
462500
* The calendar day highlight does not render
463501
* on iOS and has the same behavior across directions.
1.05 KB
Loading
973 Bytes
Loading
1.03 KB
Loading
1.07 KB
Loading
976 Bytes
Loading
1.23 KB
Loading

0 commit comments

Comments
 (0)