Skip to content

Calendar: Fill the DataForm popover with square days - #85933

Closed
oandregal wants to merge 6 commits into
trunkfrom
try/dataform-calendar-fill-container
Closed

oandregal wants to merge 6 commits into
trunkfrom
try/dataform-calendar-fill-container

Conversation

@oandregal

@oandregal oandregal commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

What?

Alternative to #85830, following this suggestion. See #76076 (this comment).

Lets the Calendar and RangeCalendar components from @wordpress/ui grow to fill their container, with square days, instead of centering the calendar in DataForm panel popovers. In the post editor's Date popover, the calendar now spans the full width of the popover and lines up with the date input above it. DataForm keeps its calendars at that same size in every layout, so they don't grow to fill wide forms.

Why?

The calendars have a fixed size: seven 32px columns. Most containers are wider (the DataForm panel popover is at least 320px), so the calendar sits against the start edge with all the spare width after it. The DataForm controls already ask for width: 100%, but the calendar grid ignores it. Fixing it in the component solves it everywhere the calendar is used.

How?

In @wordpress/ui (packages/ui/src/calendar/style.module.css):

  • The root is a block (display: flow-root) instead of an inline block, so it takes the width of its container.
  • The month grid uses width: 100% and table-layout: fixed, so the seven day columns share the available width equally. Day buttons fill their column.
  • Days stay square (aspect-ratio: 1), growing from 32px up to 48px (336px per month). This keeps the dashed range preview, drawn on a square SVG, inside its cell.
  • Calendars showing several months (numberOfMonths, up to three) lay them out in an equal-column grid: side by side when there is room, wrapping on narrow screens, and a month that wraps onto its own row stays as wide as the others. A month class name is passed to react-day-picker for this.
  • The maximum day size is a private custom property (--_wp-ui-calendar-max-cell-size).

This changes the default size of the component for every consumer, so the CHANGELOG entry is under Breaking Changes. To keep the previous size, a consumer can place the calendar in a container sized to its content.

In @wordpress/dataviews:

  • The date, datetime, and date range controls cap the calendar at 288px, the width it has inside the panel layout's 320px popover. The calendar looks the same in the regular layout and in the panel popover, instead of growing to 336px (and as tall) in wide forms.
  • Inside the panel popover, the cap is lifted, so the calendar fills the popover even when other content makes it wider.
  • The Layout Panel story now lists the date field. It was already defined in the story but not shown in the panel, and it is the quickest way to check the calendar inside a DataForm panel popover.

Open questions:

  • Is 48px the right maximum day size in @wordpress/ui, and 288px the right calendar width in DataForm?
  • Should filling the container be the default in @wordpress/ui, as here, or opt-in?

Testing Instructions

  1. Open a post in the post editor.
  2. In the Post tab of the inspector, open the Date field.
  3. Check that the calendar spans the width of the popover, with its edges aligned with the date input.
  4. In Storybook, open DataViews > DataForm > Layout Panel and open the Date field. The calendar fills the popover.
  5. In Storybook, open DataViews > DataForm > Layout Regular. The calendars are 288px wide with square days, the same size as in the panel popover, and start at the left edge.
  6. In Storybook, open Design System > Components > Calendar > RangeCalendar and set numberOfMonths to 2 or 3. The months sit side by side and wrap when the window is narrow; a wrapped month is as wide as the others. Select a start date and hover a later one: the dashed preview stays within its row.
  7. Repeat a few of these checks in an RTL language.

Testing Instructions for Keyboard

Only the calendar's size changes. Tab into the Date popover and use the arrow keys, Page Up, and Page Down to move between days and months to check the calendar still works as before.

Screenshots or screencast

Inspector

Before After
Screenshot 2026-10-30 at 14 46 33 Screenshot 2026-10-30 at 14 44 56

DataForm panel popover (Storybook, Layout Panel):

Before After
Date fields popover with calendars against the left edge and empty space on their right Date fields popover with calendars spanning its full width, aligned with the inputs

DataForm regular layout (Storybook, Layout Regular):

Before After
Regular layout date and datetime fields with small calendars under full-width inputs Regular layout date and datetime fields with larger calendars, at the same size as in the panel popover

DataViews filter popover and a regular form side by side. The filter popover is narrower than 288px, so its calendar stays at the minimum size:

Before After
Date filter popover next to a regular form with a small calendar Date filter popover unchanged, next to a regular form with a larger calendar

Date range filter popover with a selected range:

Before After
Date range filter popover with a selected range on the calendar Date range filter popover with a selected range on the calendar, at the same size

Use of AI Tools

This PR was written with Claude Code (Claude Opus 5.5), which made the change, checked it in Storybook, and ran the calendar and DataForm control unit tests. I reviewed the change and took the screenshots.

@oandregal oandregal added [Type] Enhancement A suggestion for improvement. [Package] DataViews /packages/dataviews [Package] UI /packages/ui labels Oct 29, 2026
Copilot AI balanced review requested due to automatic review settings October 29, 2026 10:48
@oandregal
oandregal requested review from a team, gigitux and ntsekouras as code owners October 29, 2026 10:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @rahul05ranjan.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: rahul05ranjan.

Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: +808 B (+0.01%)

Total Size: 8.57 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 542 kB +183 B (+0.03%)
build/scripts/edit-site/index.min.js 376 kB +124 B (+0.03%)
build/scripts/editor/index.min.js 559 kB +193 B (+0.03%)
build/scripts/media-utils/index.min.js 232 kB +164 B (+0.07%)
build/styles/edit-site/style-rtl.css 20.6 kB +20 B (+0.1%)
build/styles/edit-site/style-rtl.min.css 16.7 kB +13 B (+0.08%)
build/styles/edit-site/style.css 20.6 kB +20 B (+0.1%)
build/styles/edit-site/style.min.css 16.7 kB +13 B (+0.08%)
build/styles/editor/style-rtl.css 30.7 kB +18 B (+0.06%)
build/styles/editor/style-rtl.min.css 26.4 kB +21 B (+0.08%)
build/styles/editor/style.css 30.7 kB +18 B (+0.06%)
build/styles/editor/style.min.css 26.3 kB +21 B (+0.08%)

b5e6cd7 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 618dff4 trunk % Change
timeToFirstByte 57.85 ms +9.59% -4.75% 59.1 ms +12.01% -3.47% -2.12%
largestContentfulPaint 98 ms +6.12% -6.12% 96 ms +6.25% -4.17% 2.08%
lcpMinusTtfb 37.35 ms +17.54% -8.57% 35.5 ms +3.66% -3.66% 5.21%
wpBeforeTemplate 29.65 ms +16.83% -0.88% 30.62 ms +11.04% -3.1% -3.17%
wpTemplate 23.32 ms +9.39% -7.38% 23.94 ms +4.8% -2.88% -2.59%
wpTotal 54.17 ms +8.75% -5.43% 55.07 ms +12.18% -3.56% -1.63%
wpMemoryUsage 7.70 MB +0% -0% 7.67 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 618dff4 trunk % Change
timeToFirstByte 44.2 ms +6.56% -1.58% 48.35 ms +4.24% -4.03% -8.58%
largestContentfulPaint 92 ms +4.35% -0% 100 ms +4% -0% -8%
lcpMinusTtfb 48.25 ms +1.45% -1.45% 53.5 ms +2.15% -1.03% -9.81%
wpBeforeTemplate 26.88 ms +11.94% -0.86% 26.88 ms +4.91% -2.08% 0%
wpTemplate 13.73 ms +6.41% -1.97% 17.83 ms +3.14% -8.3% -22.99%
wpTotal 41.19 ms +6.07% -1.51% 44.81 ms +5.45% -3.82% -8.08%
wpMemoryUsage 6.28 MB +0% -0% 6.36 MB +0% -0% -1.22%
wpDbQueries 9 +0% -0% 13 +0% -0% -30.77%

media-processing

Metric 618dff4 trunk % Change
mediaProcessingJpeg 406.75 ms +1.38% -1.35% 397.77 ms +1.07% -0.99% 2.26%
mediaProcessingAvif 6173.53 ms +0.15% -0.18% 6163.01 ms +0.26% -0.15% 0.17%
mediaProcessingJpegToAvif 4233.3 ms +0.84% -0.17% 4237.11 ms +0.44% -0.02% -0.09%

media-upload

Metric 618dff4 trunk % Change
jpegUploadProcessing 1966.33 ms +0.56% -1.85% 1713.03 ms +13.14% -14.17% 14.79%
pngUploadProcessing 255.3 ms +5.15% -29.95% 257.81 ms +3.22% -30.89% -0.97%
largeJpegUploadProcessing 1952.84 ms +0.81% -1.02% 1483.8 ms +31.16% -0.56% 31.61%
multipleImageUploadProcessing 2079.09 ms +0.75% -1.18% 2072.09 ms +0.28% -1.23% 0.34%

post-editor

Metric 618dff4 trunk % Change
serverResponse 349.25 ms +4.02% -2.76% 331.86 ms +6.76% -4.87% 5.24%
firstPaint 383.98 ms +11.61% -49.86% 207.33 ms +69.49% -5.27% 85.2%
domContentLoaded 709.3 ms +3.52% -1.7% 704.65 ms +0.61% -2.55% 0.66%
loaded 710.39 ms +3.52% -1.72% 705.47 ms +0.65% -2.53% 0.7%
firstContentfulPaint 417.94 ms +3.26% -8.03% 418.71 ms +0.74% -6.73% -0.18%
firstBlock 2186.79 ms +1.28% -1.3% 2167.98 ms +1.42% -2.33% 0.87%
type 16.54 ms +2.54% -8.22% 15.69 ms +5.86% -10.58% 5.42%
typeWithoutInspector 17.04 ms +7.57% -10.62% 16.38 ms +2.44% -11.29% 4.03%
typeWithTopToolbar 21.65 ms +5.77% -11.45% 20.01 ms +6.75% -6.15% 8.2%
typeContainer 7.38 ms +5.15% -11.52% 6.76 ms +11.24% -5.47% 9.17%
focus 97.16 ms +8.01% -3.62% 92.48 ms +8.01% -1.04% 5.06%
firstFocus 207.67 ms +0% -0% 206.13 ms +0% -0% 0.75%
selectAll 328.35 ms +2.39% -0.05% 321 ms +0.13% -2.31% 2.29%
undo 27.33 ms +3.55% -3.29% 25.49 ms +4.55% -2.43% 7.22%
listViewOpen 64.62 ms +6.11% -4.49% 59.08 ms +8.63% -4.4% 9.38%
inserterOpen 36.94 ms +2.87% -7.61% 33.83 ms +9.28% -6.62% 9.19%
inserterHover 9.94 ms +8.95% -6.24% 9.51 ms +6.31% -8.2% 4.52%
inserterSearch 7.18 ms +5.57% -6.82% 7.16 ms +4.47% -3.91% 0.28%
loadPatterns 514.87 ms +2.56% -2.96% 490.53 ms +5.1% -3.63% 4.96%
wpTotal 340.17 ms +4.18% -2.76% 323.02 ms +6.76% -5% 5.31%
wpMemoryUsage 14.73 MB +0% -0% 14.72 MB +0% -0% 0.1%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 618dff4 trunk % Change
serverResponse 270.96 ms +9.23% -2.72% 275.59 ms +7.53% -6.99% -1.68%
firstPaint 200.08 ms +10.02% -3.92% 214.35 ms +60.42% -20.32% -6.66%
domContentLoaded 647.62 ms +1.34% -1.76% 600.52 ms +3.75% -2.39% 7.84%
loaded 648.8 ms +1.29% -1.74% 601.54 ms +3.76% -2.43% 7.86%
firstContentfulPaint 374.64 ms +5.51% -2.52% 351.45 ms +4.89% -2% 6.6%
firstBlock 2486.85 ms +0.31% -2.63% 2331.69 ms +2% -2.71% 6.65%
type 16.09 ms +6.46% -7.83% 13.31 ms +3.61% -5.94% 20.89%
navigate 94.83 ms +9.37% -4.09% 88.28 ms +4.32% -1.09% 7.42%
loadPatterns 879.43 ms +3.18% -1.59% 904.45 ms +22.11% -13.73% -2.77%
loadPages 994.97 ms +1.55% -1.86% 965.43 ms +1.79% -3% 3.06%
wpTotal 264.11 ms +8.56% -3.62% 268.77 ms +7.68% -7.21% -1.73%
wpMemoryUsage 12.77 MB +0% -0% 12.73 MB +0% -0% 0.27%
wpDbQueries 44.5 +1.12% -1.12% 44.5 +1.12% -1.12% 0%

b5e6cd7 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 6,
+   "offset": 6,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
does not select blocks in the canvas preview when editing from the sidebar in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: getByRole('listbox', { name: 'Search results' })
Expected: visible
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeVisible" getByRole('listbox', { name: 'Search results' }) with timeout 5000ms
  - waiting for getByRole('listbox', { name: 'Search results' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:423:33)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:3
should place the caret at the click position when clicking a block that is not selected in /test/e2e/specs/editor/various/writing-flow.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

@@ -1,9 +1,9 @@
  Array [
    Object {
      "attributes": Object {
-       "content": "First!",
+       "content": "First",
      },
      "name": "core/paragraph",
    },
    Object {
      "attributes": Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/writing-flow.spec.js:952:41

b5e6cd7 Run

rahul05ranjan

This comment was marked as abuse.

@jameskoster

Copy link
Copy Markdown
Contributor

Is 48px the right maximum column width?

Seems reasonable for now.

The main question for me is whether --wp-ui-calendar-cell-size should scale to ensure the day-buttons remain square.

@t-hamano

Copy link
Copy Markdown
Contributor

Thanks for the PR! I haven’t found an ideal solution yet either, but the current approach has some side effects.

First, the dashed range preview in RangeCalendar. The preview SVGs use viewBox="0 0 32 32" and keep their aspect ratio, so when a cell becomes 48×32 the SVG grows to 48×48. Its bottom edge then spills into the next row:

5-range-preview-overlap

Second, with numberOfMonths, when the months wrap, the month left on its own line grows wider than the others, so their widths no longer match:

4-three-months-wrap

@WordPress/gutenberg-components, I’d appreciate your ideas.

To summarize the current approach: to fill the empty space on the right of the DataForm popover, ui/Calendar grows to fill its parent container, while the width of each day cell is capped.

oandregal and others added 5 commits October 30, 2026 13:58
The story defined a datetime field but left it out of the form, so the
calendar in a panel popover had no example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The calendars had a fixed size of seven 32px columns, so wider
containers, such as the DataForm date popover, left uneven space
beside them. Render them as a block whose day columns share the
available width, up to 48px each, while keeping the 32px day height.
Calendars showing several months keep them side by side, each capped
at the same width, and still wrap on narrow screens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Day buttons now keep a 1:1 aspect ratio as they grow, so the dashed range
preview SVGs (drawn on a square viewBox) no longer spill into the next row.

Months are laid out in an equal-column grid instead of a wrapping flex row,
so a month that wraps onto its own row stays as wide as the others. Each
month is still capped at the maximum day size when months stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New `--wp-ui-*` custom properties are public API and the prefix is frozen,
so use the private `--_wp-ui-*` prefix for the internal maximum day size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Calendar and RangeCalendar now grow to fill their container, which made
them up to 336px wide (and as tall) in the regular layout. Cap the calendar
at the width it has in the panel layout's 320px popover, so it looks the
same in every layout, and let it fill the popover when other content makes
the popover wider.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oandregal
oandregal force-pushed the try/dataform-calendar-fill-container branch from a17c2b0 to fbe4bee Compare October 30, 2026 13:37
@oandregal oandregal changed the title UI: Let Calendar and RangeCalendar fill their container Calendar: Fill the DataForm popover with square days Oct 30, 2026
@oandregal

Copy link
Copy Markdown
Member Author

I've pushed changes so that day cells stay square (up to 48px), which also fixes the ranges, and wrapped months keep the same width as the others. In DataForm, the calendar is capped at the panel popover's width (288px), so it doesn't grow taller in wide forms.

Screenshots:

Inspector

Before After
Screenshot 2026-10-30 at 14 46 33 Screenshot 2026-10-30 at 14 44 56

DataForm panel popover (Storybook, Layout Panel):

Before After
Date fields popover with calendars against the left edge and empty space on their right Date fields popover with calendars spanning its full width, aligned with the inputs

DataForm regular layout (Storybook, Layout Regular):

Before After
Regular layout date and datetime fields with small calendars under full-width inputs Regular layout date and datetime fields with larger calendars, at the same size as in the panel popover

DataViews filter popover and a regular form side by side. The filter popover is narrower than 288px, so its calendar stays at the minimum size:

Before After
Date filter popover next to a regular form with a small calendar Date filter popover unchanged, next to a regular form with a larger calendar

Date range filter popover with a selected range:

Before After
Date range filter popover with a selected range on the calendar Date range filter popover with a selected range on the calendar, at the same size

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oandregal

oandregal commented Oct 30, 2026 •

Copy link
Copy Markdown
Member Author

How does this look to you? I read this is preferable to #85830

Unless I'm missing some use case, it seems to me we could go ahead with this: it's an improvement, it changes no props or types (only how the calendar sizes itself, noted under Breaking Changes in case there are external consumers), we can adjust it later if needed, and within Gutenberg the calendar is only used by DataForm/DataViews.

@jameskoster

Copy link
Copy Markdown
Contributor

I agree it's preferable to centering the calendar with large gutters on both sides. I suppose the other option would be to set the min-width on the popover content to --wpds-dimension-surface-width-xs (240px). But obviously that would affect all the other fields.

I do tend to think the calendar should be a little more flexible in terms of width. Let's see what @WordPress/gutenberg-components thinks.

Comment on lines +169 to +170
width: 100%;
min-width: calc(var(--wp-ui-calendar-cell-size) * 7);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With width: 100% on the table, its max-content width becomes the 48px cap. In any container sized to its content (a @wordpress/ui Popover, a flex row, an absolutely positioned wrapper), the calendar renders at 336px for one month and 688px for two, instead of 224px and 464px. Swapping the two values keeps the intrinsic size at the minimum and still fills a container with a definite width.

Suggested change
width: 100%;
min-width: calc(var(--wp-ui-calendar-cell-size) * 7);
width: calc(var(--wp-ui-calendar-cell-size) * 7);
min-width: 100%;

I think this was the intent anyway, since the changelog says to use width: fit-content to keep the previous size, which is false unless we fix this part.

// layout's popover (320px minus its padding), so it keeps the same size in
// every layout instead of growing to its maximum in wide forms.
.dataviews-controls__calendar {
width: 100%;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The calendar root is a block now, and the column Stack stretches it, so this isn't needed.

Suggested change
width: 100%;

@ciampo

ciampo commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

I think the direction is correct, but I think that an even better approach is to make Calendar and RangeCalendar fully fluid - ie. they can render from a minimum width and stretch to occupy all the width available from their parent wrapper.

There are definitely a few challenges, especially about date range selection. I'm proposing an approach in #86086

@oandregal

Copy link
Copy Markdown
Member Author

I'm going to close this one in favor of Marco's (thanks!).

@oandregal oandregal closed this Nov 3, 2026
@oandregal
oandregal deleted the try/dataform-calendar-fill-container branch November 3, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] DataViews /packages/dataviews [Package] UI /packages/ui [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants