Skip to content

[lexical-playground] Bug Fix: Keep a chip's time when a day is picked - #9933

Merged
zurfyx merged 2 commits into
mainfrom
zurfyx/datetime-keep-time-on-day-pick
Nov 17, 2026
Merged

zurfyx merged 2 commits into
mainfrom
zurfyx/datetime-keep-time-on-day-pick

Conversation

@zurfyx

@zurfyx zurfyx commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Description

Follow-up to #9930. The date picker shows an instant at local midnight without a time, and picking a day for it stored an all-day date, so the time was lost. Two ways to get there:

  • A chip set to 09:00 in Seoul is 00:00 in London. Picking a day in a London tab made it all-day for everyone.
  • A user types 00:00, closes the picker, reopens it and picks a day.

handleDaySelect now keeps an instant an instant: with no time to apply, it stores local midnight of the picked day, which is what it did before #9930. Only an all-day date or a chip without a date stays all-day. To make an older all-day chip (local midnight) a real all-day date, check and uncheck the time box (test (r)).

Changeset

None, playground only.

Test plan

Before

(p) and (q) are new in DateTimeComponent.test.tsx, run on main (America/New_York):

$ pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeComponent.test.tsx
     × (p) keeps a timed chip at local midnight timed when a day is picked 67ms
     × (q) keeps a typed 00:00 when a day is picked after reopening 116ms
AssertionError: expected '2026-11-01' to be '2026-11-01T04:00:00.000Z' // Object.is equality
AssertionError: expected '2026-11-01' to be '2026-11-01T04:00:00.000Z' // Object.is equality
      Tests  2 failed | 17 passed (19)

After

$ pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeComponent.test.tsx
      Tests  20 passed (20)

$ pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTime
 Test Files  6 passed (6)
      Tests  99 passed (99)

$ pnpm vitest run --project unit packages/lexical-playground
 Test Files  40 passed (40)
      Tests  492 passed (492)

The DateTime tests also pass (99/99) with TZ set to Europe/London, Asia/Seoul, Pacific/Apia, Pacific/Kiritimati, Pacific/Pago_Pago, Atlantic/Azores, America/Santiago and Asia/Kolkata. tsc, ESLint and Prettier are clean. I did not run the e2e suites locally; CI covers them.

## Description

Follow-up to #9930. The date picker shows an instant at local midnight without a time, and picking a day for it stored an all-day date, so the time was lost. Two ways to get there:

- A chip set to 09:00 in Seoul is 00:00 in London. Picking a day in a London tab made it all-day for everyone.
- A user types 00:00, closes the picker, reopens it and picks a day.

`handleDaySelect` now keeps an instant an instant: with no time to apply, it stores local midnight of the picked day, which is what it did before #9930. Only an all-day date or a chip without a date stays all-day. To make an older all-day chip (local midnight) a real all-day date, check and uncheck the time box.

## Changeset

None, playground only.

## Test plan

### Before

`(p)` and `(q)` are new in `DateTimeComponent.test.tsx`, run on `main` (America/New_York):

```
$ pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeComponent.test.tsx
     × (p) keeps a timed chip at local midnight timed when a day is picked 67ms
     × (q) keeps a typed 00:00 when a day is picked after reopening 116ms
AssertionError: expected '2026-11-01' to be '2026-11-01T04:00:00.000Z' // Object.is equality
AssertionError: expected '2026-11-01' to be '2026-11-01T04:00:00.000Z' // Object.is equality
      Tests  2 failed | 17 passed (19)
```

### After

```
$ pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeComponent.test.tsx
      Tests  19 passed (19)

$ pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTime
 Test Files  6 passed (6)
      Tests  98 passed (98)

$ pnpm vitest run --project unit packages/lexical-playground
 Test Files  40 passed (40)
      Tests  491 passed (491)
```

The DateTime tests also pass (98/98) with `TZ` set to Europe/London, Asia/Seoul, Pacific/Apia, Pacific/Kiritimati, Pacific/Pago_Pago, Atlantic/Azores, America/Santiago and Asia/Kolkata. `tsc`, ESLint and Prettier are clean. I did not run the e2e suites locally; CI covers them.
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Nov 17, 2026 6:30am UTC
lexical-playground Ready Ready Preview Nov 17, 2026 6:30am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 17, 2026
@rootnode-bot

rootnode-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 6:43 AM UTC

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
lexical

npm i https://pkg.pr.new/lexical@9933

@lexical/a11y

npm i https://pkg.pr.new/@lexical/a11y@9933

@lexical/clipboard

npm i https://pkg.pr.new/@lexical/clipboard@9933

@lexical/code

npm i https://pkg.pr.new/@lexical/code@9933

@lexical/code-core

npm i https://pkg.pr.new/@lexical/code-core@9933

@lexical/code-prism

npm i https://pkg.pr.new/@lexical/code-prism@9933

@lexical/code-shiki

npm i https://pkg.pr.new/@lexical/code-shiki@9933

@lexical/compiler

npm i https://pkg.pr.new/@lexical/compiler@9933

@lexical/devtools-core

npm i https://pkg.pr.new/@lexical/devtools-core@9933

@lexical/dragon

npm i https://pkg.pr.new/@lexical/dragon@9933

@lexical/eslint-plugin

npm i https://pkg.pr.new/@lexical/eslint-plugin@9933

@lexical/extension

npm i https://pkg.pr.new/@lexical/extension@9933

@lexical/fast-check

npm i https://pkg.pr.new/@lexical/fast-check@9933

@lexical/file

npm i https://pkg.pr.new/@lexical/file@9933

@lexical/hashtag

npm i https://pkg.pr.new/@lexical/hashtag@9933

@lexical/headless

npm i https://pkg.pr.new/@lexical/headless@9933

@lexical/history

npm i https://pkg.pr.new/@lexical/history@9933

@lexical/html

npm i https://pkg.pr.new/@lexical/html@9933

@lexical/internal

npm i https://pkg.pr.new/@lexical/internal@9933

@lexical/link

npm i https://pkg.pr.new/@lexical/link@9933

@lexical/list

npm i https://pkg.pr.new/@lexical/list@9933

@lexical/mark

npm i https://pkg.pr.new/@lexical/mark@9933

@lexical/markdown

npm i https://pkg.pr.new/@lexical/markdown@9933

@lexical/mdast

npm i https://pkg.pr.new/@lexical/mdast@9933

@lexical/offset

npm i https://pkg.pr.new/@lexical/offset@9933

@lexical/overflow

npm i https://pkg.pr.new/@lexical/overflow@9933

@lexical/plain-text

npm i https://pkg.pr.new/@lexical/plain-text@9933

@lexical/react

npm i https://pkg.pr.new/@lexical/react@9933

@lexical/rich-text

npm i https://pkg.pr.new/@lexical/rich-text@9933

@lexical/selection

npm i https://pkg.pr.new/@lexical/selection@9933

@lexical/table

npm i https://pkg.pr.new/@lexical/table@9933

@lexical/tailwind

npm i https://pkg.pr.new/@lexical/tailwind@9933

@lexical/text

npm i https://pkg.pr.new/@lexical/text@9933

@lexical/utils

npm i https://pkg.pr.new/@lexical/utils@9933

@lexical/y

npm i https://pkg.pr.new/@lexical/y@9933

@lexical/yjs

npm i https://pkg.pr.new/@lexical/yjs@9933

commit: 0d8f7e6

@rootnode-bot rootnode-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This looks good to me. Keeping a midnight instant as an instant when a day is picked fixes the lost time in both cases from the description. The new tests (p) and (q) fail on main with the all-day value and pass here. The suggestions below are optional and non-blocking.

Optional suggestions

  1. Let the time box describe a midnight instant. In packages/lexical-playground/src/nodes/DateTimeNode/DateTimeComponent.tsx, includeTime (line 99) is false for an instant at local midnight, because getTimeValue hides midnight. The picker therefore opens with the time box unchecked and empty. After this change, a day pick keeps that chip timed (lines 201-202), so the box no longer predicts the result. For example, a London user picking a day for a chip set to 09:00 in Seoul sees "no time" before and after the pick, while the Seoul user still sees 09:00. You could open the picker with the box checked (00:00) for any non-empty instant and keep the chip text without a time. Unchecking would then be the visible way to make a chip all-day.
  2. Test the check-then-uncheck route. The description says that checking and then unchecking the time box turns an older all-day chip into a real all-day date. That works: a chip at localInstant(2026, 11, 4) becomes 2026-11-04. But no test covers it for a midnight chip, since test (b) starts from 09:00. A test next to (p) in packages/lexical-playground/__tests__/unit/DateTimeComponent.test.tsx would keep the route working.

No changeset is needed: AGENTS.md and CONTRIBUTING.md exempt playground-only changes.

Automated review (maintainer link)

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.

…day from the time box

## Description

Adds test `(r)`: checking and then unchecking the time box turns a chip at local midnight, such as an older all-day chip, into an all-day date.

## Test plan

### After

```
$ pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeComponent.test.tsx
      Tests  20 passed (20)
```

@rootnode-bot rootnode-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This looks good to me. Keeping a midnight instant as an instant when a day is picked fixes the lost time in both cases from the description. The new tests (p) and (q) fail on main with the all-day value and pass here. Thanks for adding (r): it now covers the check-then-uncheck route the description gives for older all-day chips.

Optional, non-blocking

  • Let the time box describe a midnight instant (packages/lexical-playground/src/nodes/DateTimeNode/DateTimeComponent.tsx, lines 98-99). includeTime is false for an instant at local midnight, because getTimeValue hides midnight, so the picker opens with the time box unchecked and empty. After this change, a day pick keeps that chip timed (lines 201-202), so the box no longer predicts the result. For example, a London user picking a day for a chip set to 09:00 in Seoul sees "no time" before and after the pick, while the Seoul user still sees 09:00. If the picker opened with the box checked (00:00) for any non-empty instant, unchecking it would be the visible way to make a chip all-day. The first assertion of (r) would change with it. This is the same point as the earlier inline comment on line 202, and a follow-up pull request is fine.

No changeset is needed: AGENTS.md and CONTRIBUTING.md exempt playground-only changes.

Automated review (maintainer link)

@zurfyx
zurfyx added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 68468cd Nov 17, 2026
57 checks passed

This branch was successfully deployed

2 active deployments
Preview – lexical — 0d8f7e64 Deployed Nov 17, 2026 by vercel[bot]
Preview – lexical-playground — 0d8f7e64 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant