Make WordPress Core

Opened 10 months ago

Last modified 6 weeks ago

#63465 new defect (bug)

Events and News Widget: Empty <ul> Appears Without City Selection Causing Layout Shift

Reported by: dvpatel's profile dvpatel Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.3
Component: Widgets Keywords: has-screenshots has-patch
Focuses: ui, css, administration Cc:

Description

When no city is selected in the WordPress Dashboard's "Events and News" widget, an empty <ul> element is still rendered. This causes an unnecessary blank space, resulting in a two-line display where only one is expected. Ideally, the <ul> should not be rendered unless actual event content exists.

Attachments (4)

Events and News Widget.png (99.7 KB) - added by dvpatel 10 months ago.
63465.diff (390 bytes) - added by dvpatel 10 months ago.
Created patch.
after patch.jpg (300.1 KB) - added by dvpatel 10 months ago.
After Patch
events-none.png (123.6 KB) - added by sabernhardt 10 months ago.
event-none list item in the widget (WordPress 6.8.1, not patched)

Download all attachments as: .zip

Change History (10)

@dvpatel
10 months ago

Created patch.

@dvpatel
10 months ago

After Patch

#1 @dvpatel
10 months ago

  • Focuses javascript removed
  • Keywords has-patch added

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


10 months ago
#2

Reduce margin to remove extra space in Events and News widget

Instead of removing the empty <ul>, this approach reduces the bottom margin, ensuring that the widget maintains a clean, single-line display without affecting layout when events are present.

Trac ticket: https://core.trac.wordpress.org/ticket/63465

#3 @dvpatel
10 months ago

  • Keywords needs-testing added

#4 @sabernhardt
10 months ago

  • Focuses ui-copy removed
  • Version changed from trunk to 6.3

The 6px bottom margin was added in [55889] for the Activity widget, but it also appears for the first .activity-block element in the Events and News widget. That changeset also assigned a zero margin for the :last-child.

If those two changes should be undone, the Activity widget spacing could still work with a rule like this:

#activity-widget .activity-block + .activity-block {
	margin-top: 6px;
}

In my site, I did not have an empty ul, however. The events list included an event-none list item with "There are no events scheduled near you at the moment. Would you like to organize a WordPress event?"

@sabernhardt
10 months ago

event-none list item in the widget (WordPress 6.8.1, not patched)

#5 @ankitkumarshah
8 months ago

Hi @dvpatel,
I also tried to reproduce the issue, but as mentioned by @sabernhardt, I was unable to find any empty ul tag instead, I got the following:

<ul class="community-events-results activity-block last" aria-hidden="false">
  <li class="event-none">			  
    There are no events scheduled near None at the moment. Would you like to <a href="https://make.wordpress.org/community/handbook/meetup-organizer/welcome/">organize a WordPress event</a>?
  </li>
</ul>

https://i.postimg.cc/TYBqycn0/Screenshot-2025-07-31-at-5-38-30-PM.png

#6 @r1k0
6 weeks ago

  • Keywords needs-testing removed

Reproduction Report

Environment

  • WordPress: 6.9
  • PHP: 8.4.17
  • Server: PHP.wasm
  • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
  • Browser: Chrome 144.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.1

Steps taken

  1. Head over to the Admin dashboard, open Chrome Dev tools and inspect the ul element under the choose a city input field.
  2. ❌ Bug is not occurring

Expected behavior

  • Theul element is not empty and contains a li element with a class of event-none.

Additional Notes

  • None

Screenshots/Screencast with results

https://i.ibb.co/Tx2B6YDd/community-activity.png

Note: See TracTickets for help on using tickets.