Make WordPress Core

Opened 28 hours ago

Last modified 14 minutes ago

#65276 accepted defect (bug)

Media Library: Date filter is offset with empty left space when type filter is hidden

Reported by: katag9k's profile katag9k Owned by: joedolson's profile joedolson
Milestone: 7.0.1 Priority: normal
Severity: normal Version: 7.0
Component: Media Keywords: has-patch
Focuses: ui, css Cc:

Description

When a wp.media() frame is opened with the library restricted to a single mime type (e.g. library: { type: 'image' }), the "Filter by type" dropdown is correctly hidden, but the "Filter by date" dropdown is left visually offset with a large empty space to its left.

Steps to reproduce (no plugin required)

  1. Open /wp-admin/post-new.php on a vanilla WP 7.0 install.
  2. In the browser DevTools console, run:
    wp.media({ library: { type: 'image' } }).open();
    
  3. Switch to the "Media Library" tab.

Expected behaviour

The "Filter by date" dropdown should render flush-left where the "Filter by type" dropdown would normally sit, as it did in WP 6.x.

Actual behaviour

The "Filter by date" dropdown is rendered in the right half of the toolbar with a large empty column to its left. Affects any media modal where the type filter is hidden (for example single-mime-type frames).

Attachments (2)

filter-by-date-offset-issue.png (314.6 KB) - added by katag9k 28 hours ago.
visible scrollbar at media modal.png (40.9 KB) - added by yogeshbhutkar 24 hours ago.
When both filtering options are visible, there also appears to be a scrollbar visible in the latest Trunk on the playground.

Download all attachments as: .zip

Change History (10)

This ticket was mentioned in Slack in #meta by katag9k. View the logs.


28 hours ago

#2 @joedolson
28 hours ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 7.0.1
  • Owner set to joedolson
  • Status changed from new to accepted

This will be caused by the use of grid layout added in [62326].

@yogeshbhutkar
24 hours ago

When both filtering options are visible, there also appears to be a scrollbar visible in the latest Trunk on the playground.

This ticket was mentioned in PR #11885 on WordPress/wordpress-develop by KhushalSainS.


24 hours ago
#3

  • Keywords has-patch added; needs-patch removed

## What?

Fixes the alignment of the "Filter by date" dropdown in the Media Library modal when the "Filter by type" dropdown is hidden.

## Why?

When a media frame is opened with the library restricted to a single MIME type, for example:

wp.media({ library: { type: 'image' } }).open();

the "Filter by type" dropdown is hidden as expected. However, the date filter was still assigned to the second column of the toolbar grid in src/wp-includes/css/media-views.css:

label[for="media-attachment-date-filters"] {
        grid-area: 1 / 2 / 2 / 3;
}

select#media-attachment-date-filters {
        grid-area: 2 / 2 / 3 / 3;
}

As a result, the date filter appeared offset to the right, leaving an empty space where the type filter would normally appear.

## How?

Updates the media toolbar grid positioning so the date filter uses the first column by default.

When the type filter is present, sibling selectors move the date filter back to the second column. This preserves the existing two-filter layout while fixing single-MIME-type media frames where the type filter is hidden.

## Screenshots

Before After
https://github.com/user-attachments/assets/76ac9130-b7bf-47fc-a18f-80e0a4ca8e52 https://github.com/user-attachments/assets/0c9657f8-9091-45ad-bb6f-a219a6c72d60

## Testing Instructions

  1. Go to /wp-admin/post-new.php.
  2. Open the browser DevTools console.
  3. Run:
wp.media({ library: { type: 'image' } }).open();
  1. Switch to the Media Library tab.
  2. Confirm that the "Filter by date" dropdown is aligned flush-left when the type filter is hidden.
  3. Open a normal media frame where both filters are visible.
  4. Confirm that "Filter by type" and "Filter by date" still appear side by side.

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

## Use of AI Tools

AI assistance: Yes
Tool(s): Codex, ChatGPT
Model(s): GPT-5.5
Used for: Testing guidance, CSS fix suggestion. Final changes were reviewed and edited by me.

#4 @wildworks
24 hours ago

When both filtering options are visible, there also appears to be a scrollbar visible in the latest Trunk on the playground.

This issue is also reported here: https://core.trac.wordpress.org/ticket/23562#comment:64

@yogeshbhutkar commented on PR #11885:


23 hours ago
#5

Thanks for the PR. One additional observation: the filter isn’t aligned with the search box in this case. This appears to be an existing issue in Trunk as well. I’ve attached a screenshot for reference.

https://github.com/user-attachments/assets/99050ba7-dc7a-4914-b304-9fd46b5b7900

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


19 hours ago
#6

## What?

Fixes the visual offset and alignment of the "Filter by date" dropdown in the Media Library modal when the "Filter by type" dropdown is hidden. It also ensures that the filters and the search input box are vertically aligned on the same row.

## Why?

When a wp.media() frame is opened with the library restricted to a single MIME type (e.g., library: { type: 'image' }), the "Filter by type" dropdown is hidden. Because column placement in the media toolbar was previously hardcoded, this caused the "Filter by date" dropdown remained offset in the second column, leaving a large empty space to its left.

## How?

CSS Grid Auto-Placement: Updated the toolbar filters in src/wp-includes/css/media-views.css to use CSS Grid auto-placement (placing labels on grid-row: 1 and selects on grid-row: 2) rather than hardcoded columns. This allows the date filter dropdown to slide flush-left naturally when the type filter is hidden.

## Screenshots

https://github.com/user-attachments/assets/e3805cc6-b6aa-4a96-86be-2fed56cfd611

## Testing Instructions

  1. Go to /wp-admin/post-new.php.
  2. Open the browser DevTools console and run:
    wp.media({ library: { type: 'image' } }).open();
    
  1. Switch to the "Media Library" tab.
  2. Confirm that the "Filter by date" dropdown is aligned flush-left (where the type filter would normally be) when the type filter is hidden.
  3. Open a normal media frame where both filters are visible (e.g. standard Media Library).
  4. Confirm that "Filter by type" and "Filter by date" still appear side by side.

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

## Use of AI Tools

AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini
Used for: Refactoring styling rules to use auto-placement grids.

KhushalSainS commented on PR #11885:


18 hours ago
#7

Hi @yogeshbhutkar,

Thank you for pointing this out. I’ve updated the patch to address the alignment issue shown in the screenshot.

The fix is scoped specifically to media frames where the type filter is hidden and only the date filter is displayed, so the default toolbar layout with both filters remains unaffected.

https://github.com/user-attachments/assets/094464fd-7295-4bfc-af7f-b2766185b9f5

This ticket was mentioned in Slack in #core by wildworks. View the logs.


14 minutes ago

Note: See TracTickets for help on using tickets.