Make WordPress Core

Opened 6 months ago

Closed 5 months ago

Last modified 5 months ago

#65296 closed defect (bug) (fixed)

Library section under Media, search bar shifts position after searching in the WordPress admin area.

Reported by: abduremon Owned by: joedolson
Priority: normal Milestone: 7.0.1
Component: Administration Version: 7.0
Severity: major Keywords: has-screenshots has-patch has-test-info dev-reviewed
Cc: Focuses: ui, administration

Description

## Issue
After installing WordPress, the search bar in the Library under Media tab section shifts position after performing a search in the admin area.

## Reproduction Steps

  • Log into the WordPress admin dashboard.
  • Go to Media → Library.
  • Search for any media item using the search bar.
  • Observed Result.

## Observed Result
After searching, the search bar jumps/shifts unexpectedly in the Library section UI.

## Expected Result
The search bar should remain stable and properly aligned after performing a search.

Attachments (2)

Screen Recording at 2026-05-21 at 03-09-46.mp4​ (281.0 KB ) - added by abduremon 6 months ago.
Library section search bar shifts position after searching in WordPress admin area.
Screen Recording at 2026-05-21 at 04-55-41.mp4​ (450.4 KB ) - added by abduremon 6 months ago.
The search bar position also shifts when using Grid View after selecting a media item and applying a date filter.

Download all attachments as: .zip

Change History (18)

@abduremon
6 months ago

Library section search bar shifts position after searching in WordPress admin area.

@abduremon
6 months ago

The search bar position also shifts when using Grid View after selecting a media item and applying a date filter.

#1 @abduremon
6 months ago

The search bar position also shifts when using Grid View after selecting a media item and applying a date filter.

Already uploaded another attachment.

#2 @abduremon
6 months ago

  • Keywords has-screenshots added

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


6 months ago
#3

  • Keywords has-patch added

## Summary

Fixes an issue where the search bar in the Media Library (Admin grid view) shifts/jumps horizontally (moves to the left and then snaps back) when typing/removing text in the search input or applying a date filter.

### Root Cause
During search/filtering updates, the Backbone.js view shows/hides the loading spinner and an overlay element (.media-bg-overlay) to block interaction and display the loading state.

However, .media-bg-overlay was only styled within the @media screen and (max-width: 782px) media query in media-views.css. On screens wider than 782px (desktop), the element had no style definitions. Consequently, when jQuery called .show(), the overlay was displayed as a default block element (display: block) in the normal document flow. Because it sits inside the .media-toolbar container, its insertion disrupted the floated and flex layout of .media-toolbar-primary (containing the search input) and .media-toolbar-secondary, causing the layout elements to shift.

### Solution

  • Defined .media-bg-overlay globally (outside of media queries) with absolute positioning. This takes the overlay out of the document flow on all screen sizes, preventing any layout reflow/shift.

## Changes

### src/wp-includes/css/media-views.css

  • Moved .media-bg-overlay layout definition to a global rule so it is always absolutely positioned and overlaying the toolbar correctly on both desktop and mobile views.

## Testing

Test Case Expected / Result Status
Typing search queries in Media Library Grid View Search bar remains stable, no horizontal shift ✅ Passed
Selecting media item and applying a Date filter Grid layout remains stable, no horizontal shift ✅ Passed

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

## Use of AI Tools

AI assistance: No

#4 @wildworks
6 months ago

  • Milestone Awaiting Review → 7.0.1

I believe this issue is a regression caused by the following style added by r61645.

.upload-php .wp-filter {
        display: flex;
}

When performing a filter search, display: block is applied to the overlay, which seems to cause unintended issues with flex layouts.

<div class="media-toolbar wp-filter"> <!-- `display: flex` is applied -->
    <div class="media-toolbar-secondary">
    </div>
    <div class="media-toolbar-primary search-form">
    </div>
    <div class="media-bg-overlay" style="display: none;"></div> <!-- `display:block` is dynamically applied here during filter search -->
</div>

​@mohamedahamed commented on ​PR #11937:


6 months ago
#5

@t-hamano Have made the changes!

#6 @wildworks
6 months ago

​PR #11937 looks good to me for commit.

#7 @khokansardar
6 months ago

Patch testing report

Patch / PR tested

Environment

  • WordPress: 7.1-alpha-62161-src
  • PHP: latest (Docker)
  • MySQL: 8.4
  • OS: macOS 26.3.1
  • Browser: Chromium, desktop viewport (>782px)
  • Local wordpress-develop @ ​http://localhost:8889

Steps
# Log in to wp-admin.
# Open Media → Library in Grid view (/wp-admin/upload.php?mode=grid).
# Use a desktop-width window (>782px).
# Type and delete text in the Search media field.
# Change the date filter (e.g. All dates → May 2026).
# Clear search and repeat.

Results

  • Typing in search (grid view): pass — no horizontal toolbar shift observed.
  • Date filter change: pass — toolbar/search bar position stable during refresh.
  • Clearing search: pass — no layout jump.

Conclusion
PR #11937 fixes the reported layout shift on desktop. Recommend commit.

#8 @khokansardar
6 months ago

  • Keywords has-test-info added

#9 @darshitrajyaguru97
6 months ago

Patch tested:

​https://github.com/WordPress/wordpress-develop/pull/11937

Environment

  • WordPress: 7.1-alpha-62161-src
  • PHP: Latest
  • MySQL: 8.4
  • OS: Windows
  • Browser: Chrome
  • Viewport: Desktop (>782px)

Test Procedure
# Sign in to the WordPress admin area.
# Navigate to Media → Library using Grid mode (/wp-admin/upload.php?mode=grid).
# Ensure the browser width remains above 782px.
# Enter text into the “Search media” input and then remove it.
# Switch the media date dropdown to another month/year option.
# Repeat the search and clear actions multiple times.

Observed Results

  • Search interactions in Grid view remained visually stable with no horizontal movement in the toolbar area.
  • Changing the date filter refreshed correctly without causing the search controls to shift position.
  • Removing the search term did not trigger any noticeable layout jump.

Final Notes
The proposed patch successfully resolves the desktop layout shift issue reported in the ticket. Tested successfully and appears ready for commit.

#10 @wildworks
6 months ago

  • Keywords commit added

#11 @joedolson
5 months ago

  • Owner set to joedolson
  • Status new → accepted

#12 @joedolson
5 months ago

  • Resolution → fixed
  • Status accepted → closed

In 62469:

Media: Fix input position shift during admin search.

Avoid layout element shift by setting position attributes on .media-bg-overlay in all viewports, avoiding redraw of flex layout.

Props abduremon, mohamedahamed, wildworks, khokansardar, darshitrajyaguru97, joedolson.
Fixes #65296.

#13 @joedolson
5 months ago

  • Keywords dev-feedback added
  • Resolution fixed
  • Status closed → reopened

Reopening for backport to 7.0 branch.

#14 @wildworks
5 months ago

  • Keywords dev-reviewed added; dev-feedback removed

Adding second committer sign-off.

#15 @cbravobernal
5 months ago

  • Resolution → fixed
  • Status reopened → closed

In 62562:

Media: Fix input position shift during admin search.

Avoid layout element shift by setting position attributes on .media-bg-overlay in all viewports, avoiding redraw of flex layout.

Reviewed by wildworks.
Merges [62469] to the 7.0 branch.

Props abduremon, mohamedahamed, wildworks, khokansardar, darshitrajyaguru97, joedolson.
Fixes #65296.

#16 @cbravobernal
5 months ago

  • Keywords commit removed
Note: See TracTickets for help on using tickets.