Skip to content

Calendar: Fill the available container width - #86086

Merged
ciampo merged 6 commits into
trunkfrom
codex/fluid-ui-calendars
Nov 9, 2026
Merged

ciampo merged 6 commits into
trunkfrom
codex/fluid-ui-calendars

Conversation

@ciampo

@ciampo ciampo commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

See #85933 for the related square-day approach. Custom day highlighting and its relationship to the today indicator are tracked separately in #86538.

What?

Make Calendar and RangeCalendar fill their container, with a default minimum of 224px per month and no maximum. Use a fixed-width or width: fit-content wrapper for a compact calendar.

Why?

The fixed-width grids leave unused space in wider containers.

How?

Months share each row equally and wrap when needed. An incomplete last row also fills its width. Days stay 32px high. The range preview SVG resizes without stretching its stroke, dashes, or corners. The today dot stays beside the centered date number as the cell widens, including in selected and range states. Its position at the minimum width is unchanged.

The dot stays close to the number because an unselected day has no visible button boundary. Anchoring it to the far corner of a wide cell separates it from the date. Both Fluid Width stories now show the current month so this can be checked while resizing.

Testing Instructions

  1. Open the Fluid Width stories for Calendar and RangeCalendar in Storybook.
  2. Resize the container using these cases:
Months Container widths Expected layout
1 224px, 448px, 700px Fills the width; the today dot stays beside the number.
2 348px, 464px, 928px Wraps at 348px; shares one row at 464px and 928px.
3 600px The last month fills the second row.
  1. Check today before and after selecting it, then focus it with the keyboard. The dot should stay in the same position beside the number while the background and focus ring cover the full cell. Check range previews before, inside, and after a selected range, including resetOnSelect: true and ranges crossing months.
  2. Check a width: fit-content wrapper or content-sized UI Popover. Expect 224px, 464px, or 704px for one, two, or three months when space allows. Below 224px, the parent controls scrolling or clipping.
  3. Navigate between months. Outgoing and incoming months should keep matching widths, including after wrapping. Repeat in RTL, dark theme, and forced colors.
  4. Check the DataForm examples linked in oandregal's comment:
    • Regular layout: check the Date and DateTime fields at wide and narrow widths. Each calendar should align with the input above it and use the available width.
    • Datetime field: select the item to open its editor. The calendar should fit the narrow editing column. Select a date and confirm that the time is preserved.
    • Validation with panel dropdowns: open Date fields and scroll through Date, Date range, and Date time. Check that calendars align with their inputs and have no horizontal clipping. At shorter viewport heights, the popup should scroll vertically. Select a date and close the popup.

Testing Instructions for Keyboard

Tab through the navigation buttons into the grid. Use arrow keys to move and Enter or Space to select. The focus ring should cover the stretched day button, including after wrapping.

Verification and limits

At 11b2ba2e2e2, build, lint, UI types, and all 227 calendar and DataForm datetime tests passed, including 20 browser tests. The latest visual checks covered the today marker, wide range previews in LTR and RTL, and all three linked DataForm examples in Chromium and WebKit. In the regular layout, calendar and input borders both measured 868px at a 900px viewport and 343px at a 375px viewport. The datetime editor calendar fit its approximately 243px column. The validation popup had no horizontal overflow at either viewport width; its longer content scrolled vertically, and date selection updated the datetime input.

Earlier checks covered month navigation and content-sized UI Popovers. Firefox, editor integration, and screen-reader testing remain unverified. This PR changes calendar sizing and the position of the existing today dot. It does not add post/event indicators or settle their design; that work remains in #86538.

Screenshots or screencast

Today marker

Captured on 9 November 2026 at 11b2ba2e2e2, in Chromium with the light theme. The date is 9 November. Day buttons stay 32px high as they widen.

Minimum width, 224px Stretched width, 700px
Today at the minimum calendar width of 224px Today beside the centered date number in a 700px calendar

At 700px, each day button is 100px wide and 32px high. Selection and keyboard focus cover that full width; the dot stays beside the number.

Today selected and keyboard-focused in a 700px calendar

The same placement applies to RangeCalendar, including selected endpoints and the dashed hover preview.

Today at a selected range endpoint, with a full-width hover preview

DataForm visual checks

Captured at 11b2ba2e2e2 in Chromium. The same layout checks passed in WebKit. These screenshots show the shared DataForm controls; they do not show the custom post-date control restored in #86065.

Regular layout, DateTime field at a 900px viewport. The input border and calendar both fill 868px. The very wide day buttons are intentional; consumers can constrain their container for a compact calendar.

DataForm DateTime input and calendar aligned at 868px

The same field at a 375px viewport. The input and calendar both fill 343px.

DataForm DateTime input and calendar aligned at a narrow viewport

Datetime field story, with the selected item open for editing. The calendar fits the approximately 243px editing column and aligns with the input above it.

Datetime field calendar fitting its narrow editing column

Validation story, Date fields popup. This capture uses a 900×1800 viewport to show all three calendars together. At shorter heights, the popup scrolls vertically.

Date, Date range, and Date time calendars aligned inside the validation popup

The same popup at a 375×1000 viewport. Its calendars fit without horizontal clipping.

Validation date-fields popup fitting a narrow viewport

Earlier before/after layout comparisons

These captures document the earlier revisions named below. The current today-marker and DataForm screenshots above supersede them for those states.

Before: aad2cfbc3bb. After: 1e3d1f4054f. Captured in Chromium with the light theme. Each pair uses the same container width, dates, hover, and keyboard focus.

Calendar, one month at 448px

Before

Before: one month leaves unused space in a 448px container

After

After: one month fills the 448px container, including hover and focus styles

RangeCalendar, two months at 928px

Before

Before: two fixed-width months leave unused space in a 928px container

After

After: two months share the 928px container equally, with a stretched hover preview and focus ring

RangeCalendar, two wrapped months at 348px

Before

Before: wrapped months stay at their minimum width in a 348px container

After

After: each wrapped month fills the 348px container, including the range preview and focus ring

More states

Captured at 1e3d1f4054f. Selected dates appear above hover and focus states. Navigation frames are paused at 35%.

Calendar, one month

Calendar with one month at the minimum width and two wider widths

Calendar, two months

Calendar with two months wrapping and sharing wider containers

RangeCalendar, one month

RangeCalendar with one month, selected ranges, hover previews, and focus

RangeCalendar, two months

RangeCalendar with two months wrapping and sharing wider containers

Additional states

Additional calendar states, including RTL, forced colors, dark theme, and WebKit

Compact popovers and navigation

Compact calendars inside content-sized UI Popovers and native month navigation at stretched widths

Use of AI Tools

Implemented and checked with OpenAI Codex.

@github-actions github-actions Bot added the [Package] UI /packages/ui label Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

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

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: oandregal <oandregal@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: -318 B (0%)

Total Size: 8.63 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 545 kB -38 B (-0.01%)
build/scripts/edit-site/index.min.js 379 kB -126 B (-0.03%)
build/scripts/editor/index.min.js 567 kB -75 B (-0.01%)
build/scripts/media-utils/index.min.js 234 kB -79 B (-0.03%)

11b2ba2 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 7311af4 trunk % Change
timeToFirstByte 34.2 ms +7.46% -4.39% 35.35 ms +13.58% -5.09% -3.25%
largestContentfulPaint 60 ms +6.67% -0% 60 ms +10% -6.67% 0%
lcpMinusTtfb 25.8 ms +9.88% -7.75% 24.35 ms +2.67% -3.08% 5.95%
wpBeforeTemplate 17.68 ms +8.99% -2.49% 18.3 ms +16.01% -3.66% -3.39%
wpTemplate 13.11 ms +3.2% -4.88% 13.78 ms +7.04% -6.31% -4.86%
wpTotal 31.03 ms +9.02% -4.45% 32.23 ms +15.14% -4.84% -3.72%
wpMemoryUsage 7.72 MB +0% -0% 7.69 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 7311af4 trunk % Change
timeToFirstByte 27.75 ms +8.83% -0.9% 29.55 ms +6.6% -5.92% -6.09%
largestContentfulPaint 64 ms +6.25% -0% 64 ms +6.25% -0% 0%
lcpMinusTtfb 36.5 ms +3.84% -0.68% 36.25 ms +5.66% -4.97% 0.69%
wpBeforeTemplate 15.66 ms +3.26% -2.3% 15.89 ms +9.75% -2.33% -1.45%
wpTemplate 9.87 ms +3.34% -2.53% 10.59 ms +3.78% -8.78% -6.8%
wpTotal 25.39 ms +8.7% -1.22% 26.81 ms +6.79% -5.26% -5.3%
wpMemoryUsage 6.41 MB +0% -0% 6.38 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 7311af4 trunk % Change
mediaProcessingJpeg 220.48 ms +0.02% -1.04% 214.5 ms +0.98% -0.5% 2.79%
mediaProcessingAvif 3531.94 ms +1.1% -0.46% 3640.57 ms +1.29% -0.47% -2.98%
mediaProcessingJpegToAvif 2443.25 ms +0.32% -0.49% 2490.11 ms +1.16% -0.39% -1.88%

media-upload

Metric 7311af4 trunk % Change
jpegUploadProcessing 1398.24 ms +1.57% -0.54% 1392.56 ms +1.01% -0.41% 0.41%
pngUploadProcessing 169.19 ms +5.45% -1.61% 183.86 ms +9.08% -6.25% -7.98%
largeJpegUploadProcessing 1408.98 ms +0.42% -0.97% 1410.07 ms +0.64% -1.41% -0.08%
multipleImageUploadProcessing 1455.04 ms +0.58% -0.6% 1466.78 ms +0.47% -0.09% -0.8%

post-editor

Metric 7311af4 trunk % Change
serverResponse 332.76 ms +4.06% -8.71% 318.87 ms +1.66% -8.96% 4.36%
firstPaint 386.08 ms +2.11% -27% 295.68 ms +30.43% -14.29% 30.57%
domContentLoaded 680.59 ms +2.57% -1.58% 673.06 ms +1.15% -1.24% 1.12%
loaded 681.47 ms +2.59% -1.6% 673.89 ms +1.15% -1.24% 1.12%
firstContentfulPaint 396.6 ms +2.51% -0.82% 391.54 ms +3.83% -1.5% 1.29%
firstBlock 1780.39 ms +1.24% -1.63% 1768.32 ms +1.27% -0.52% 0.68%
type 15.79 ms +6.08% -10.7% 14.93 ms +2.01% -11.59% 5.76%
typeWithoutInspector 15.95 ms +2.32% -15.61% 15.47 ms +5.04% -11.38% 3.1%
typeWithTopToolbar 19.55 ms +8.95% -7.67% 18.7 ms +7.01% -2.94% 4.55%
typeContainer 7.05 ms +15.89% -8.65% 6.85 ms +10.07% -7.3% 2.92%
focus 93.41 ms +2.7% -5.75% 91.53 ms +9.79% -1.39% 2.05%
firstFocus 197.76 ms +0% -0% 196.73 ms +0% -0% 0.52%
selectAll 311.76 ms +5.42% -1.68% 305.06 ms +3.13% -0.69% 2.2%
undo 24.84 ms +11.71% -3.58% 24.99 ms +10.64% -6.52% -0.6%
listViewOpen 63.48 ms +8.05% -8.65% 59.39 ms +6.77% -9.78% 6.89%
inserterOpen 33.03 ms +4.54% -4.39% 32.17 ms +7.86% -7.99% 2.67%
inserterHover 9.71 ms +3.81% -5.25% 9.2 ms +5% -6.09% 5.54%
inserterSearch 6.85 ms +6.86% -3.36% 6.9 ms +8.55% -5.07% -0.72%
loadPatterns 506.87 ms +2.36% -1.71% 530.18 ms +2.78% -4.41% -4.4%
wpTotal 323.58 ms +4.31% -8.84% 310.25 ms +1.71% -9.25% 4.3%
wpMemoryUsage 14.77 MB +0% -0% 14.74 MB +0% -0% 0.24%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 7311af4 trunk % Change
serverResponse 275.13 ms +0.93% -1.63% 269.3 ms +1.08% -9.18% 2.16%
firstPaint 298.05 ms +13.7% -27.52% 256.96 ms +10.32% -11.59% 15.99%
domContentLoaded 616.09 ms +6.38% -2.65% 613.55 ms +3.55% -3.11% 0.41%
loaded 616.95 ms +6.38% -2.64% 614.46 ms +3.55% -3.12% 0.41%
firstContentfulPaint 359.43 ms +9.48% -2.82% 354.75 ms +6.15% -2.74% 1.32%
firstBlock 1797.61 ms +3.28% -1.19% 1828.25 ms +1.39% -1.44% -1.68%
type 13.91 ms +3.31% -6.69% 13.72 ms +2.41% -9.4% 1.38%
navigate 89.47 ms +7.43% -6.2% 83.53 ms +9.66% -8.25% 7.11%
loadPatterns 1001.13 ms +5.36% -22.11% 883.88 ms +18.93% -9.68% 13.27%
loadPages 951.82 ms +0.28% -0.47% 978.16 ms +1.47% -2.41% -2.69%
wpTotal 268.34 ms +0.75% -1.61% 262.62 ms +1.09% -9.41% 2.18%
wpMemoryUsage 12.79 MB +0% -0% 12.75 MB +0% -0% 0.27%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

11b2ba2 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.

As a user I expect my navigation to use the colors I selected for it in /test/e2e/specs/editor/blocks/navigation-colors.spec.js, passed after 1 failed attempt.
Error: locator.click: Error: strict mode violation: getByRole('option', { name: 'Cyan bluish gray' }) resolved to 2 elements:
    1) <button type="button" role="option" tabindex="-1" aria-selected="false" aria-label="Cyan bluish gray" id="components-circular-option-picker-1-13" class="components-button components-circular-option-picker__option is-next-40px-default-size"></button> aka locator('#components-circular-option-picker-1-13')
    2) <button type="button" role="option" tabindex="-1" aria-selected="false" aria-label="Cyan bluish gray" id="components-circular-option-picker-2-25" class="components-button components-circular-option-picker__option is-next-40px-default-size"></button> aka locator('#components-circular-option-picker-2-25')

Call log:
  - waiting for getByRole('option', { name: 'Cyan bluish gray' })

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-colors.spec.js:324:5
Page List converts to Navigation Links with entity bindings in /test/e2e/specs/editor/blocks/navigation.spec.js, passed after 1 failed attempt.
Error: expect(locator).toContainText(expected) failed

Locator: getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ })
Expected substring: "test-page-1"
Received string:    "Link to:Cat/catPagePublished"
Timeout: 5000ms

Call log:
  - Expect "toContainText" getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ }) with timeout 5000ms
  - waiting for getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ })
    14 × locator resolved to <button type="button" aria-expanded="false" aria-haspopup="dialog" class="components-button link-preview-button is-next-40px-default-size is-secondary">…</button>
       - unexpected value "Link to:Cat/catPagePublished"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation.spec.js:1949:31
does not select blocks in the canvas preview when editing from the sidebar (Site Editor v2) in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator: getByRole('combobox', { name: 'Search or type URL' })
Expected: focused
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeFocused" getByRole('combobox', { name: 'Search or type URL' }) with timeout 5000ms
  - waiting for getByRole('combobox', { name: 'Search or type URL' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:416:47)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:21
should allow user to add and remove multiple local font files in /test/e2e/specs/admin/font-library.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: getByLabel('Exo 2 Semi-bold Italic')
Expected: visible
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeVisible" getByLabel('Exo 2 Semi-bold Italic') with timeout 5000ms
  - waiting for getByLabel('Exo 2 Semi-bold Italic')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/admin/font-library.spec.js:58:6
should undo without broken temporary state in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:image -->
- <figure class="wp-block-image"><img alt=""/></figure>
+ <!-- wp:image {"id":20,"sizeSlug":"full","linkDestination":"none"} -->
+ <figure class="wp-block-image size-full"><img src="http://localhost:8891/wp-content/uploads/2026/11/e0cf498c-3542-4c34-9c48-7b3b6db604d6.png" alt="" class="wp-image-20"/></figure>
  <!-- /wp:image -->
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/image.spec.js:432:49

11b2ba2 Run

@ciampo ciampo self-assigned this Oct 31, 2026
@ciampo
ciampo marked this pull request as ready for review October 31, 2026 14:32
@ciampo
ciampo requested a review from a team as a code owner October 31, 2026 14:32
@ciampo
ciampo requested review from a team and oandregal October 31, 2026 14:32
@ciampo ciampo added the [Type] Enhancement A suggestion for improvement. label Oct 31, 2026
@jasmussen

Copy link
Copy Markdown
Contributor

Seems good. I guess it also goes in the other direction, squishing if it grows smaller. But perhaps the main container has a min-width here.

@ciampo

ciampo commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

We can look into whether it's possible to squish it to a lower min width than the current one, but I feel like that's a lower priority (I'd prefer to keep this PR focused and shippable quick)

@jorgefilipecosta jorgefilipecosta left a comment •

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.

Things tested well and the code looks good 👍 I left some minor non blocking comments

@mirka mirka left a comment

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.

Was this design considered with the current day marker in mind? I don't see a single screenshot for that so I'm not sure. I don't think the the current day marker design (small dot on the top right corner) works with anything other than a tight square.

@oandregal

Copy link
Copy Markdown
Member

FWIW, since we've added custom edit controls for the date fields (not using the bundled datetime control) this doesn't need to be backported to 7.2. It's still an issue we need to address so we can use the default datetime controls in any date field.

There's stories that highlight this usage (e.g., DataForm regular layout, datetime field) — perhaps the best one is the validation story with panel layout (date fields):

Screenshot 2026-11-04 at 13 10 52

@ciampo
ciampo force-pushed the codex/fluid-ui-calendars branch from 1e3d1f4 to 11b2ba2 Compare November 9, 2026 17:19
@ciampo

ciampo commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

All feedback addressed.

The "today" marker stays close to the date number, at least in this first iteration, since it felt like the safest way to make sure it stayed "understandable" regardless of the calendar width.

Image Image

@ciampo
ciampo merged commit e85ab41 into trunk Nov 9, 2026
98 checks passed
@ciampo
ciampo deleted the codex/fluid-ui-calendars branch November 9, 2026 17:55
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 9, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
* Calendar: Fill the available container width

* Calendar: Document fluid sizing in the changelog

* Calendar: Preserve minimum widths in content-sized containers

* Calendar: Preserve stretched widths during month navigation

* Calendar: Remove redundant layout and SVG declarations

* Calendar: Keep today markers beside dates at fluid widths

---

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants