Make WordPress Core

Opened 4 weeks ago

Closed 11 days ago

#65647 closed defect (bug) (fixed)

On This Day: The behavior is strange when there is nothing to display

Reported by: wildworks Owned by: joedolson
Priority: normal Milestone: 7.1
Component: Widgets Version: trunk
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

Related to #65116

Props to @welcher; I discovered this problem while watching his livestream.

The On This Day widget is visually hidden using the hidden class when there is nothing to display.

https://github.com/WordPress/wordpress-develop/blob/d6b46699b2d4d81390af8bb0cdb03ff7fd31c583/src/wp-admin/includes/dashboard-on-this-day.php#L44-L50

However, this causes confusion because the "On This Day" option is checked in the Screen Options, making it unclear why the widget isn't visible. Furthermore, if you uncheck and then recheck the option, the widget becomes visually apparent as the JavaScript injects the display: block style.

Testing Instructions

  1. Access the dashboard and confirm that the "On This Day" widget is not displayed.
  2. Open Screen Options and verify that "On This Day" is checked.
  3. Uncheck it once, then check it again.
  4. The "On This Day" widget will then be visually displayed.

Proposed solutions

Here are two solutions that come to mind.

  1. Display the widget even when there is no content to show. In other words, stop injecting the hidden class.
  2. Use a CSS class with !important instead of hidden to always overwrite the JavaScript injection of display:block.

Attachments (4)

Before.png (116.5 KB ) - added by mirmpro 3 weeks ago.
After.png (116.6 KB ) - added by mirmpro 3 weeks ago.
before-patch.png (121.5 KB ) - added by shailu25 3 weeks ago.
Before Patch
after-patch.png (118.8 KB ) - added by shailu25 3 weeks ago.
After Patch

Download all attachments as: .zip

Change History (34)

#1 @iamchitti
4 weeks ago

Digging into this, the root cause is that two independent hide mechanisms are fighting each other:

  • The server-side hidden class (display: none) added by wp_dashboard_on_this_day_postbox_classes() when there are no posts to show.
  • The Screen Options checkbox, which is a persisted per-user preference. Because the widget isn't in the user's hidden-metaboxes list, the box stays checked.

So the checkbox reports "shown" while the widget is actually hidden by our class. And when you uncheck/recheck, postbox.js calls jQuery's .show(), which injects an inline display: block that overrides .hidden — revealing the widget. Hence the inconsistent behavior.

Weighing the two proposed solutions:

  1. Always show the widget (drop the hidden class)
    • Fixes the confusion at its root — the checkbox state and the widget's visibility now agree.
    • Defers hiding to WordPress's existing, well-understood mechanism: if a user doesn't want the widget, they uncheck it in Screen Options and that preference persists correctly.
    • Consistent with widgets like Activity and At a Glance, which always render even when nearly empty. The placeholder message ("No posts were published on this day in previous years.") already exists and is informative.
    • Trade-off: an empty widget occupies some dashboard space on quiet days — but this is honest, least-surprising, and fully under user control.
  1. Use a CSS class with !important instead of hidden
    • Does not resolve the root confusion — the checkbox still reads "checked" while the widget is invisible.
    • Breaks the documented "user can reveal it via Screen Options" behavior, because !important beats the inline display: block that jQuery injects on recheck.
    • Relies on !important, which core CSS generally avoids; it papers over the JS/CSS conflict rather than resolving it.

Given the above, approach 1 is the cleaner fix: it removes the mismatch entirely, respects the user's Screen Options control, and avoids !important. The only cost — a placeholder on quiet days — is consistent with other always-registered dashboard widgets.

I'll raise a PR implementing approach 1 (removing the postbox_classes filter so the widget always renders.

This ticket was mentioned in PR #12575 on WordPress/wordpress-develop by @iamchitti.


4 weeks ago
#2

  • Keywords has-patch has-unit-tests added

## Trac ticket

https://core.trac.wordpress.org/ticket/65647

## Problem

The On This Day dashboard widget is hidden with the core hidden class when there are no posts to show for the current calendar day. This creates inconsistent, confusing behavior:

  • The widget is not visible on the dashboard, but its Screen Options checkbox is still checked — so the reported state disagrees with what's actually shown.
  • Unchecking and re-checking the option reveals the widget, because postbox.js calls jQuery's .show(), which injects an inline display: block that overrides the .hidden class.

The root cause is two independent hide mechanisms competing: a server-side hidden class vs. the persisted per-user Screen Options preference.

## Fix

Take the "always show" approach (option 1 from the ticket):

  • Remove the postbox_classes_dashboard_wp_dashboard_on_this_day filter and the wp_dashboard_on_this_day_postbox_classes() function that added the hidden class.
  • The widget is now always registered and always visible. When there are no matching posts, the existing placeholder — _"No posts were published on this day in previous years."_ — is shown.
  • Hiding is deferred entirely to Screen Options, which persists correctly and keeps the checkbox state consistent with on-screen visibility.

This is consistent with other always-registered dashboard widgets (e.g. _Activity_, _At a Glance_) and avoids !important CSS hacks.

## Testing instructions

  1. Ensure there are no published posts dated on today's month/day in a previous year (a recent install satisfies this by default).
  2. Visit the Dashboard.
  3. Before this change: the widget is not visible, yet "On This Day" is checked in Screen Options; unchecking and re-checking reveals it.
  4. After this change: the widget is always visible and shows the placeholder message; the Screen Options checkbox state matches its visibility. Unchecking hides it and the preference persists across reloads.

## Screenshots

Before

https://github.com/user-attachments/assets/8632be89-bc3d-4442-81de-da3da7b5fecc

After

https://github.com/user-attachments/assets/23bb9961-f82b-4fed-8408-3c96a115da1e

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.8
Used for: update unit tests

#3 @joedolson
4 weeks ago

While always showing the widget is cleaner, and a clearer user interaction, hiding it when there's no information was a specific comment from @matt; we should get some clarity on whether this is a viable approach.

This ticket was mentioned in Slack in #core-test by huzaifaalmesbah. View the logs.


3 weeks ago

#5 @mirmpro
3 weeks ago

Patch Test Report

Description
Tested #65647 to verify that the "On This Day" dashboard widget always renders with the empty placeholder message when there are no past posts on the current date, resolving the visibility mismatch with Screen Options.

Environment

  • WordPress: 7.1-beta3
  • Subdirectory: No
  • PHP: 8.2.29
  • Server: nginx/1.26.1
  • Database: mysqli (Server: 8.0.35 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 150.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.3.0
    • WordPress Beta Tester 4.0.0

Steps to Test

  1. Ensure there are no published posts on the site dated today's month/day from previous years.
  2. Navigate to the Admin Dashboard.
  3. Confirm that the "On This Day" widget is visible by default, showing *"No posts were published on this day in previous years."*
  4. Open Screen Options and verify that the "On This Day" checkbox is checked (matching visual visibility).
  5. Uncheck "On This Day" in Screen Options; verify the widget hides cleanly.
  6. Re-check "On This Day" in Screen Options; verify the widget appears correctly.
  7. Refresh the page to confirm that the preference persists across page reloads.

Expected Results

  1. The widget and Screen Options checkbox state are always in sync.
  2. When there are no matching posts, the widget remains visible displaying the informative placeholder message.
  3. Hiding/showing via Screen Options works seamlessly without CSS or inline style conflicts.

Actual Results

  1. Patch works as expected. The "On This Day" widget is displayed continuously with the placeholder message, and toggling via Screen Options behaves predictably without unexpected behavior.

Additional Notes
- Patch tested

Supplemental Artifacts
Added as Attachment

Last edited 3 weeks ago by mirmpro (previous) (diff)

@mirmpro
3 weeks ago

@mirmpro
3 weeks ago

#6 @joedolson
3 weeks ago

  • Owner set to joedolson
  • Status newaccepted

#7 @ugyensupport
3 weeks ago

Test Report

Description

The On This Day widget is visually hidden using the hidden class when there is nothing to display.

https://github.com/WordPress/wordpress-develop/blob/d6b46699b2d4d81390af8bb0cdb03ff7fd31c583/src/wp-admin/includes/dashboard-on-this-day.php#L44-L50

However, this causes confusion because the "On This Day" option is checked in the Screen Options, making it unclear why the widget isn't visible. Furthermore, if you uncheck and then recheck the option, the widget becomes visually apparent as the JavaScript injects the display: block style.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/12575/changes

Environment

  • WordPress: 7.0.3-alpha-62793
  • Subdirectory: No
  • PHP: 8.4.14
  • Server: nginx/1.21.4
  • Database: mysqli (Server: 5.7.44-log / Client: mysqlnd 8.4.14)
  • Browser: Chrome 150.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.3.0
    • WordPress Beta Tester 4.0.0
    • WP File Manager 8.0.4

Steps to Reproduce

Ensure there are no published posts on the site dated today's month/day from previous years.
Navigate to the Admin Dashboard.
Confirm that the "On This Day" widget is visible by default, showing *"No posts were published on this day in previous years."*
Open Screen Options and verify that the "On This Day" checkbox is checked (matching visual visibility).
Uncheck "On This Day" in Screen Options; verify the widget hides cleanly.
Re-check "On This Day" in Screen Options; verify the widget appears correctly.
Refresh the page to confirm that the preference persists across page reloads.

Expected Results

The widget and Screen Options checkbox state are always in sync.
When there are no matching posts, the widget remains visible, displaying the informative placeholder message.
Hiding/showing via Screen Options works seamlessly without CSS or inline style conflicts.

Actual Results

  1. Patch Works ✅
Last edited 3 weeks ago by ugyensupport (previous) (diff)

#8 @shailu25
3 weeks ago

Test Report

This Report Validates that the indicated patch address the issue.✅

Patch Tested: https://github.com/WordPress/wordpress-develop/pull/12575

Environment:

WordPress - 7.1-beta1-20260717.050507
OS - Windows
Browser - Chrome
Theme: Twenty Twenty Five
PHP - 7.4.33
Plugin - None

Actual Results:

  • Issue Resolved with Patch ✅

Supplemental Artifacts

  • Attached

@shailu25
3 weeks ago

Before Patch

@shailu25
3 weeks ago

After Patch

#9 @wildworks
3 weeks ago

While always showing the widget is cleaner, and a clearer user interaction, hiding it when there's no information was a specific comment from @matt; we should get some clarity on whether this is a viable approach.

Please note that we need to clarify and agree on this point before testing and proceeding with the attached patch.

#10 @iamraju
3 weeks ago

Test Report

Patch tested: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/12575.diff

Environment

  • WordPress: 7.1-beta1-20260717.050507
  • Subdirectory: No
  • PHP: 7.4.33
  • Server: PHP.wasm
  • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
  • Browser: Chrome 150.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.3.0

Steps taken

  1. Reproduced the bug on 7.1-beta1-20260717.050507
  2. Tested the Patch on Playground

✅ Verified that the patch is solving the problem

#11 @wildworks
3 weeks ago

  • Versiontrunk

#12 @nazmulasif
3 weeks ago

Test Report

Patch tested: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/12575.diff

Environment

  • WordPress: 7.1-alpha-20260717
  • Subdirectory: No
  • PHP: 8.4
  • Server: PHP.wasm
  • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
  • Browser: Chrome 150.0.0.0
  • OS: macOS 26
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.3.0

Steps taken

  1. Accessed the WordPress dashboard where the "On This Day" widget had no content to display and verified it was hidden while remaining checked under Screen Options.
  2. Applied and tested the patch from patch using the WordPress Playground preview environment.
  3. Re-evaluated the "On This Day" widget container behavior to ensure proper visibility logic and prevent JS injection UI conflicts.
  • ✅ Patch is solving the problem

Expected result

  • The "On This Day" dashboard widget and Screen Options checkbox behavior should remain properly aligned, preventing UI confusion and unwanted visibility toggles when no content is present.

Additional Notes

  • Successfully tested and verified patch. The patch correctly resolves the bug where unchecking and rechecking Screen Options forced an empty widget to display due to JavaScript style injection conflicts.

Screenshots/Screencast with results

  • N/A

Support Content

@wildworks commented on PR #12575:


2 weeks ago
#13

I have made two changes to this PR. It is ready for re-review.

  • dc0aea507b89b3aeafdf04e21aeb5f6504c84ad3: Resolve conflicts.
  • d218c56c885149a07deb1d1782dfa5c3d71db745: Remove the wp_dashboard_on_this_day_setup function. This is because it is now merely a wrapper for wp_add_dashboard_widget and is deemed to have no further purpose.

@wildworks commented on PR #12575:


2 weeks ago
#14

I've been thinking about this, and I'm leaning towards supporting this PR that always displays the On This Day widget.

@m suggested hiding the On This Day widget entirely when there's no content to display. However, implementing this presents some tricky challenges. A significant issue is that the widget might be visually absent, yet its checkbox in the Screen Options would still appear.

https://github.com/user-attachments/assets/c246c5b4-160a-4171-bf72-6911153c7629

While we can hide the "On This Day" checkbox within Screen Options, it requires a somewhat convoluted approach.

Furthermore, the current behavior might be perceived as a bug. Please refer to this livestream by Ryan. https://www.twitch.tv/videos/2821389287?t=42m35s

@annezazu @joedolson, I plan to move forward with this PR, what are your thoughts?

@annezazu commented on PR #12575:


2 weeks ago
#15

Thanks for surfacing this. I agree in having it always on, both to avoid technical concerns and to prevent confusion around the checkbox problem. I can see how that would be confusing. Since this means the empty state will be more readily visible, perhaps we can spruce it up from this:

https://github.com/user-attachments/assets/190f67f4-b409-4caa-b283-f33cceaf8dae

For example, here's what site health shows:

https://github.com/user-attachments/assets/29ff81a2-3fd0-457c-838a-13b355802d8d

Maybe something like this, where we link to "Add post"?

https://github.com/user-attachments/assets/e961d0d9-e3a7-4a5d-8451-5c1143590ea4

@WordPress/gutenberg-design for any empty state thoughts here :)

@joedolson commented on PR #12575:


2 weeks ago
#16

I agree with this. Ultimately, hiding it creates a lot of technical problems that are largely unnecessary, and creates a user experience that's potentially confusing.

I feel like the text should be more invitational; something like "You haven't published a post on this day before. Write one now, and be reminded about it next year!"

But I think getting some copy work on this would be good; and we need to nail that down by RC, for translators sakes.

@annezazu commented on PR #12575:


2 weeks ago
#17

I like your text more than mine (and don’t feel strongly). Another option: “No posts were published on this day in previous years. Write one today, and be reminded about it next year.”

@iamchitti commented on PR #12575:


2 weeks ago
#18

I like the prompt by @joedolson - "Write one today, and be reminded about it next year". But ideally, if published on the day, it will be shown next year on same date. So, I guess it should be "Publish one today, and be reminded about it next year".

Let me know once copy is finalized. I will do the final copy update quickly.

@paaljoachim commented on PR #12575:


2 weeks ago
#19

I see the dashboard as an area that is meant to focus on the customers site to where they can gain useful information. On keeping On This Day dashboard widget....not sure I see the use in that...sorry. I do see it kind of like a history widget though. Like a curiosity...

@Joen commented on PR #12575:


2 weeks ago
#20

Things moving fast here, good work all around. I'll try and respond primarily to the ping on the empty-state.

Which is to say, in the current context and widget implementation, it largely works to prompt and explain. It's a pity we can't hide it when it's empty: I endorse moving forward without that feature in the name of iteration, but nevertheless I want to acknowledge the instinct: when it's populated it's a moment of delight. When it's empty, it's a question: why is this here? Not blocking, but encouraging future iteration in this space.

And it's extra context for tweaking the help text, because for me it suggests that the text should be as minimal as possible, so that it serves as the lightest write-prompt+explanation we can muster, but otherwise reduce its footprint so it doesn't annoy. In that sense, we could go one of these directions:

  • Nothing here yet. [Write today's post].
  • No posts on this day yet. [Start one now] for next year.
  • This day is empty. [Write something] worth revisiting.

I can understand an argument to want to stay verbose afterall: on a big screen two lines of text might not feel like a lot. But the problem is: on many blogs, and certainly many static sites that aren't used as blogs, you'll see this text a lot, which is why I'm leaning towards less text. (Also a question: can we/is the widget already hidden if a site has no posts at all?)

Nevertheless if you want the more verbose text, you could go in one of these directions:

  • Anne's option: No posts were published on this day in previous years. [Write one today], and be reminded about it next year.
  • Today's archive is empty for now. [Write something today] to start filling it in.
  • Nothing was written on this day before. [Start today] to change that.

@wildworks commented on PR #12575:


2 weeks ago
#21

I tried the suggested text. I would love to hear your feedback.

No posts were published on this day in previous years. (Current text)

https://github.com/user-attachments/assets/8b3270d4-3f54-4088-aaf6-61ec9f5450c7

Nothing here yet. [Write today's post].

https://github.com/user-attachments/assets/80deaa31-fed2-40b9-bd74-ad968875f76d

No posts on this day yet. [Start one now] for next year.

https://github.com/user-attachments/assets/325c2547-66c8-4f5b-851c-45dff2ae3058

This day is empty. [Write something] worth revisiting.

https://github.com/user-attachments/assets/baa6e9e3-42c9-47b4-9cbc-137014aae8f7

No posts were published on this day in previous years. [Write one today], and be reminded about it next year.

https://github.com/user-attachments/assets/9cdc9ca1-ed44-4d92-8fd4-db9cbdd70537

Today's archive is empty for now. [Write something today] to start filling it in.

https://github.com/user-attachments/assets/753b825d-c429-470a-9d4d-9be3304305f5

Nothing was written on this day before. [Start today] to change that.

https://github.com/user-attachments/assets/76d036c1-23c6-4426-8a69-bbb5d309d0fd

@joedolson commented on PR #12575:


2 weeks ago
#22

Many widgets are only useful to some users - the majority of users will never attend a WordPress event and are unconcerned with WordPress news. I don't think we need to concern ourselves too much with whether or not all users will benefit from it. Users who use the dashboard at all will customize it to their needs - other users won't use it, and it will make little difference to them what's there.

I don't particularly like using 'empty'; it doesn't feel very friendly to me. I'm also not thrilled with "Write something worth revisiting", as it puts unnecessary pressure by setting a value judgement on publishing.

My preference from above would be "Nothing here yet. [Write today's post]." Short and to the point.

@wildworks commented on PR #12575:


2 weeks ago
#23

My preference from above would be "Nothing here yet. [Write today's post]." Short and to the point.

I tried this.

@annezazu commented on PR #12575:


2 weeks ago
#24

I don't think that really connects what the widget does though and we need to assume folks need that connection. I'd prefer we go with this:

No posts were published on this day in previous years. [Write one today], and be reminded about it next year.

I think it matches a friendliness in our interface that we shouldn't be afraid to have (think "hello dolly" vibes), especially when looking at the approach for the events widget that asks people to consider organizing an event.

@wildworks commented on PR #12575:


13 days ago
#25

No posts were published on this day in previous years. [Write one today], and be reminded about it next year.

I have changed the wording. I don't have a strong opinion on the phrasing, but in any case, it might be best to commit this PR towards RC1 and gather user feedback.

@mukesh27 commented on PR #12575:


13 days ago
#26

It might be best to commit this PR towards RC1 and gather user feedback.

Go for it @t-hamano

#27 @joedolson
12 days ago

  • Keywords commit added

I'm agreeing with @wildworks that it would be best to commit this and gather feedback. There's certainly nothing wrong with the friendly text; it has a good vibe - and we could discuss possible phrasing indefinitely without coming to a clear "best possible phrase".

Marking for commit.

#28 @joedolson
12 days ago

  • Keywords commit removed

In principle this is commit ready, but the tests need to be reworked a bit, so I'm going to move it out of commit for now.

@wildworks commented on PR #12575:


12 days ago
#29

The unit test failures should be resolved now.

#30 @joedolson
11 days ago

  • Resolutionfixed
  • Status acceptedclosed

In 62977:

Widgets: Always render the On This Day widget.

While the intention was to only render the On This Day widget when it returned results, this proved to create a variety of implementation complications and some significant points of confusion for users.

Remove the conditional rendering of the On This Day widget. When active without posts, display a message inviting the user to publish a new post.

Developed in https://github.com/WordPress/wordpress-develop/pull/12575

Props iamchitti, mirmpro, shailu25, ugyensupport, iamraju, nazmulasif, wildworks, joedolson, mukesh27, annezazu, paaljoachim, joen.
Fixes #65647.

Note: See TracTickets for help on using tickets.