Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,37 @@ describe('DateTimeComponent', () => {
expect(readValue()).toBe(localInstant(2026, 11, 4));
});

// An instant at local midnight shows without a time, but it can be a time
// set in another time zone (09:00 in Seoul is 00:00 in London) or a typed
// 00:00, so picking a day must not turn it into an all-day date
it('(p) keeps a timed chip at local midnight timed when a day is picked', async () => {
await mountChip(localInstant(2026, 11, 4));
await openPicker();
const day = await pickOtherDay();
expect(readValue()).toBe(localInstantOn(day, 0));
});

it('(q) keeps a typed 00:00 when a day is picked after reopening', async () => {
await mountChip('2026-11-04');
await openPicker();
await clickCheckbox();
await typeTime('00:00');
await closePicker();
await openPicker();
const day = await pickOtherDay();
expect(readValue()).toBe(localInstantOn(day, 0));
});

it('(r) makes a chip at local midnight all-day by checking and unchecking the time box', async () => {
await mountChip(localInstant(2026, 11, 4));
await openPicker();
expect(readPicker()).toEqual([false, '']);
await clickCheckbox();
expect(readValue()).toBe(localInstant(2026, 11, 4));
await clickCheckbox();
expect(readValue()).toBe('2026-11-04');
});

it('(d) keeps the stored time when the time field is empty', async () => {
await mountChip(localInstant(2026, 11, 4, 9));
await openPicker();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,18 @@ export default function DateTimeComponent({
if (date === undefined) {
return;
}
// A typed time, or else the time the chip already has; with neither the
// day is all-day
// A typed time, or else the time the chip already has. An instant shown
// without a time is at local midnight, which can be a time set in another
// time zone or a typed 00:00, so it keeps that midnight. Only an all-day
// date or a chip without a date stays all-day.
const time = parseTime(timeValue) ?? parseTime(storedTime);
withDateTimeNode(node => {
if (time === null) {
if (time !== null) {
node.setDateTime(withTime(date, time));
} else if (node.isAllDay() || node.getDateTimeValue() === '') {
node.setAllDayDate(date);
} else {
node.setDateTime(withTime(date, time));
node.setDateTime(withTime(date, [0, 0]));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, non-blocking: this branch keeps a midnight instant timed, but for that chip includeTime (line 99) is false, so the picker shows the time box unchecked and empty both before and after the pick. A London user picking a day for a chip set to 09:00 in Seoul sees "no time" while Seoul keeps 09:00. You could open the picker with the box checked (00:00) whenever the value is a non-empty instant, so that unchecking is the visible way to go all-day.

}
});
};
Expand Down
Loading