Skip to content

DataForm: Center the calendar in panel popovers - #85830

Closed
oandregal wants to merge 5 commits into
trunkfrom
fix/dataform-calendar-alignment
Closed

oandregal wants to merge 5 commits into
trunkfrom
fix/dataform-calendar-alignment

Conversation

@oandregal

@oandregal oandregal commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

What?

See #76076 (this comment).

Centers the calendar of the DataForm date and datetime controls when they are shown in a panel popover, so it no longer leaves uneven space on its right. This shows up in the post editor's Date popover now that the DataForm-based inspector is stable. Inline forms (for example, the regular layout) keep the calendar at the start edge, as before.

Why?

The Calendar and RangeCalendar components from @wordpress/ui have a fixed size (seven 32px columns). The panel popover is a little wider (at least 320px), so the calendar sat against the start edge with all the spare width after it.

How?

  • Give the three calendars in packages/dataviews/src/components/dataform-controls/ (single date, date range, and datetime) a dataviews-controls__calendar class, replacing the inline width: 100%. The column Stack around them already stretches them to the full width, so inline forms look the same.
  • In the panel layout styles, center that calendar only inside .dataforms-layouts-panel__field-dropdown. Centering is symmetric, so it works the same in RTL.

The post Date field uses the stock datetime control and its popover has nothing field-specific to target, so the fix applies to every date and datetime field shown in a panel popover (post editor inspector, Quick Edit, and any other DataForm using the panel layout), rather than to the Date field alone.

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 is centered in the popover, with the same space on both sides.
  4. In Storybook, open DataViews > DataForm > Layout Panel, open the Date field, and check the calendar is centered in the popover. The story now includes the date field. For the date and date range calendars, open DataViews > DataForm > Validation, set layout to panel-dropdown, and open "Date fields".
  5. In Storybook, open DataViews > DataForm > Layout Regular and check the calendars are still at the start edge, as on trunk.

Testing Instructions for Keyboard

Only the calendar's position changes. Tab into the Date popover and use the arrow keys to move between days to check the calendar still works as before.

Screenshots or screencast

Before After
Date popover with the calendar against its left edge and a wide gap on the right Screenshot 2026-10-28 at 12 26 37

Use of AI Tools

This PR was written with Claude Code (Claude Opus 5.5), which investigated the issue, made the change, and checked it in Storybook and with the unit tests. I reviewed the change.

The calendar has a fixed size, so stretching its root to the full width
of the control left its grid stuck to the start edge, with an uneven gap
after it (for example, in the post editor's Date popover). Center it
instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oandregal oandregal added [Type] Bug An existing feature does not function as intended [Package] DataViews /packages/dataviews labels Oct 28, 2026
oandregal and others added 2 commits October 28, 2026 12:04
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 28, 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: oandregal <oandregal@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: yashjawale <yashjawale@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: aduth <aduth@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: +79 B (0%)

Total Size: 8.56 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 542 kB +6 B (0%)
build/scripts/edit-site/index.min.js 376 kB +3 B (0%)
build/scripts/editor/index.min.js 556 kB +7 B (0%)
build/scripts/media-utils/index.min.js 231 kB +5 B (0%)
build/styles/edit-site/style-rtl.css 20.6 kB +8 B (+0.04%)
build/styles/edit-site/style-rtl.min.css 16.7 kB +3 B (+0.02%)
build/styles/edit-site/style.css 20.6 kB +8 B (+0.04%)
build/styles/edit-site/style.min.css 16.6 kB +4 B (+0.02%)
build/styles/editor/style-rtl.css 30.2 kB +7 B (+0.02%)
build/styles/editor/style-rtl.min.css 25.9 kB +9 B (+0.03%)
build/styles/editor/style.css 30.2 kB +9 B (+0.03%)
build/styles/editor/style.min.css 25.8 kB +10 B (+0.04%)

28e26fa 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: 'Pale cyan blue' }) resolved to 2 elements:
    1) <button type="button" role="option" tabindex="-1" aria-selected="false" aria-label="Pale cyan blue" id="components-circular-option-picker-0-9" class="components-button components-circular-option-picker__option is-next-40px-default-size"></button> aka locator('#components-circular-option-picker-0-9')
    2) <button type="button" role="option" tabindex="-1" aria-selected="false" aria-label="Pale cyan blue" id="components-circular-option-picker-1-21" class="components-button components-circular-option-picker__option is-next-40px-default-size"></button> aka locator('#components-circular-option-picker-1-21')

Call log:
  - waiting for getByRole('option', { name: 'Pale cyan blue' })

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-colors.spec.js:315: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:1780: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
inserts a block should show a blue line indicator in /test/e2e/specs/editor/various/inserting-blocks.spec.js, passed after 1 failed attempt.
TimeoutError: locator.boundingBox: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('data-testid=block-list-insertion-point-indicator')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/inserting-blocks.spec.js:678:41
should create paragraph on Enter in quote block in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('option', { name: 'List', exact: true })

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:751:67
should cut and paste individual blocks with collapsed selection in /test/e2e/specs/editor/various/copy-cut-paste.spec.js, passed after 1 failed attempt.
Error: expect(string).toMatchSnapshot(expected) failed

  @@ -1,3 +1,3 @@
   <!-- wp:paragraph -->
  -<p>2Cut - collapsed selection</p>
  +<p>2</p>
   <!-- /wp:paragraph -->


    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/copy-cut-paste.spec.js:45:49
should format text across blocks in /test/e2e/specs/editor/various/multi-block-selection.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": "ab",
+       "content": "b",
      },
      "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/multi-block-selection.spec.js:2219:41
should give the image its context menu while selected @WebKit @Firefox in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Test timeout of 100000ms exceeded.
should keep the list type when indenting an ordered list item in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

@@ -1,8 +1,8 @@
  <!-- wp:list {"ordered":true} -->
  <ol class="wp-block-list"><!-- wp:list-item -->
- <li>one<!-- wp:list {"ordered":true} -->
+ <li>ne<!-- wp:list {"ordered":true} -->
  <ol class="wp-block-list"><!-- wp:list-item -->
  <li>two</li>
  <!-- /wp:list-item --></ol>
  <!-- /wp:list --></li>
  <!-- /wp:list-item --></ol>

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:916:52
should merge a following sibling list into the outermost list with Delete from a nested item (#77245) in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

@@ -8,11 +8,11 @@
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {
                  "attributes": Object {
-                   "content": "b‸",
+                   "content": "b",
                  },
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
@@ -25,11 +25,11 @@
    },
    Object {
      "innerBlocks": Array [
        Object {
          "attributes": Object {
-           "content": "1",
+           "content": "‸1",
          },
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:2854:41
should not have a dead zone between blocks (lower) in /test/e2e/specs/editor/various/writing-flow.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: locator('role=button[name="Add block"i]')
Expected: visible
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeVisible" locator('role=button[name="Add block"i]') with timeout 5000ms
  - waiting for locator('role=button[name="Add block"i]')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/writing-flow.spec.js:981:28
should restore an older wp_template revision in /test/e2e/specs/editor/various/revisions.spec.js, passed after 1 failed attempt.
Error: apiRequestContext.get: socket hang up
Call log:
  - → GET http://localhost:8891/wp-admin/themes.php
    - user-agent: Playwright/1.63.0 (x64; ubuntu 24.04) node/24.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_da433b7faafd8180ebeb1624ceeeab7e=admin%7C1793359845%7Ct7njLReBqryTFx1ZuVc1URemm0Bq2XHMpHr2Y6OWuMe%7C71c022fc915c5394fa8f734f5db74c26f6291523532bd8c71b28f80c7f2c9d9f; wordpress_logged_in_da433b7faafd8180ebeb1624ceeeab7e=admin%7C1793359845%7Ct7njLReBqryTFx1ZuVc1URemm0Bq2XHMpHr2Y6OWuMe%7Cf34ed448e37cb726bff99c619a0d627dc9355e02e0bf93a2b42fbdb9891bb730; wp-settings-time-1=1793187397

    at RequestUtils.activateTheme (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/themes.ts:7:36)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/revisions.spec.js:700:22
should select by dragging into nested block in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 1
+ Received  + 0

  Array [
    1,
-   2,
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:568:5
should update the URL from the last navigation if only varies in the URL fragment in /test/e2e/specs/interactivity/router-navigate.spec.ts, passed after 1 failed attempt.
Error: expect(locator).toHaveText(expected) failed

Locator:  getByTestId('title')
Expected: "Link 1"
Received: "Main"
Timeout:  5000ms

Call log:
  - Expect "toHaveText" getByTestId('title') with timeout 5000ms
  - waiting for getByTestId('title')
    14 × locator resolved to <h2 data-testid="title">Main</h2>
       - unexpected value "Main"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigate.spec.ts:160:25
themes can override registered templates (Site Editor v2) in /test/e2e/specs/site-editor/template-registration.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: getByText('AuthorEmptytheme')
Expected: visible
Error: strict mode violation: getByText('AuthorEmptytheme') resolved to 5 elements:
    1) <div data-wp-c16t="true" data-wp-component="Flex" class="e518617e7c3a18e7__flex _3896336788892095__items-row cc39999a5fb580d4__expanded-row components-flex dataviews-view-grid__field">…</div> aka locator('[id="emptytheme//category"]').getByText('AuthorEmptytheme')
    2) <div data-wp-c16t="true" data-wp-component="Flex" class="e518617e7c3a18e7__flex _3896336788892095__items-row cc39999a5fb580d4__expanded-row components-flex dataviews-view-grid__field">…</div> aka locator('[id="emptytheme//custom-template"]').getByText('AuthorEmptytheme')
    3) <div data-wp-c16t="true" data-wp-component="Flex" class="e518617e7c3a18e7__flex _3896336788892095__items-row cc39999a5fb580d4__expanded-row components-flex dataviews-view-grid__field">…</div> aka locator('[id="emptytheme//index"]').getByText('AuthorEmptytheme')
    4) <div data-wp-c16t="true" data-wp-component="Flex" class="e518617e7c3a18e7__flex _3896336788892095__items-row cc39999a5fb580d4__expanded-row components-flex dataviews-view-grid__field">…</div> aka locator('[id="emptytheme//singular"]').getByText('AuthorEmptytheme')
    5) <div data-wp-c16t="true" data-wp-component="Flex" class="e518617e7c3a18e7__flex _3896336788892095__items-row cc39999a5fb580d4__expanded-row components-flex dataviews-view-grid__field">…</div> aka locator('[id="emptytheme//tag"]').getByText('AuthorEmptytheme')

Call log:
  - Expect "toBeVisible" getByText('AuthorEmptytheme') with timeout 5000ms
  - waiting for getByText('AuthorEmptytheme')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/template-registration.spec.js:191:56

28e26fa Run

@oandregal

oandregal commented Oct 28, 2026 •

Copy link
Copy Markdown
Member Author

These changes make the control center-aligned in every situation. This is how it looks in the storybook when it's used in a regular layout:

Before After
Screenshot 2026-10-28 at 12 13 59 Screenshot 2026-10-28 at 12 14 04

Centering the calendar in every date and datetime control moved it in
wide inline forms too, where it sat at the start edge before. Restore
that layout and center the calendar only inside the panel popover,
where the popover is a little wider than the calendar and the uneven
gap shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oandregal oandregal changed the title DataForm: Center the calendar in the date and datetime controls DataForm: Center the calendar in panel popovers Oct 28, 2026
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>
@oandregal

Copy link
Copy Markdown
Member Author

These changes make the control center-aligned in every situation. This is how it looks in the storybook when it's used in a regular layout:

I've addressed this by making it center-aligned only when in panel mode:

before after
Screenshot 2026-10-28 at 12 23 23 Screenshot 2026-10-28 at 12 22 20

@oandregal
oandregal marked this pull request as ready for review October 28, 2026 11:27
Copilot AI balanced review requested due to automatic review settings October 28, 2026 11:27

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.

@oandregal

Copy link
Copy Markdown
Member Author

cc @verofasulo

@yashjawale

Copy link
Copy Markdown
Contributor

Thanks! 🙌

This looks a lot better than having empty space on right.

image

I wonder if its possible to make the popover have less width so there isn't extra space on the sides. Don't think any of the other elements will get affected by it.

@oandregal

Copy link
Copy Markdown
Member Author

I wonder if its possible to make the popover have less width so there isn't extra space on the sides. Don't think any of the other elements will get affected by it.

The popover's width is dynamic and has a floor at 320px.

This same issue was discussed at #76325 and the min-width changed to 256 at #76345 but then raised back (intentionally) to 320 at #75204

I'll leave @jameskoster @ciampo comment on this. I'll be happy to reduce the minimum if that's in line with design tokens in place, but I don't consider that decision a blocker to land this fix.

@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.

From the code point of view things look good 👍 May need some design eyes to validate the approach.

@jameskoster

Copy link
Copy Markdown
Contributor

I forget if there's a reason why we don't allow it, but the better approach might be to allow calendars to grow to fill their container.

@oandregal

Copy link
Copy Markdown
Member Author

I forget if there's a reason why we don't allow it, but the better approach might be to allow calendars to grow to fill their container.

I've prepared this alternative at #85933

@aduth

aduth commented Oct 30, 2026

Copy link
Copy Markdown
Member

Coming to this a bit late, and trying to connect some dots: #76325 already identified this issue previously, and at the time the consensus was around reducing the width of the popover from 320px to 256px. The width reduction was implemented in #76345, but then #75204 changed it back to 320px with a note that it is intended "so option labels have more room before truncating". Both this pull request and #85933 treat the popover's width as some fixed value to work within, but the past shows that we'd previously addressed this by changing the popover width itself.

Ultimately we'd probably want these to be using tokens anyways, and we have options --wpds-dimension-surface-width-xs (240px) and --wpds-dimension-surface-width-sm (320px), but these tokens don't really have clearly documented semantics.

Certainly not trying to block anything here and this pull request or #85933 would be better than the current state, I just want to make sure we're not retreading ground we've already solved once, and making sure we're clear on what the intended end-state is.

@ciampo

ciampo commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

I think that having the calendar stretch would be a better solution, that would decouple from any decision made about the width of the popover. I'll take a look at #85933

@oandregal

Copy link
Copy Markdown
Member Author

I'm going to close this one. There's #85933 and #86086 (the latter is the more promising). We can reopen later if needed.

@oandregal oandregal closed this Nov 3, 2026
@oandregal
oandregal deleted the fix/dataform-calendar-alignment 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 [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants