Trac #65151: Fix dashboard widget drag-and-drop glitch#12034
Trac #65151: Fix dashboard widget drag-and-drop glitch#12034kabir-coderex wants to merge 1 commit into
Conversation
…area heights and improving placeholder styles
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Description
This PR resolves the glitchy drag-and-drop behavior encountered when rearranging widgets on the WordPress admin dashboard. Specifically, it fixes the layout calculations, visibility degradation, and viewport clipping that occur when dragging widgets across uneven columns or when the action requires page scrolling.
Problems Addressed
.meta-box-sortablesdrop area. Because each column is only as tall as its own widgets, dragging a widget toward a shorter column (or below its last widget) left no droppable region, so no placeholder appeared even though the drop itself worked.:not(.empty-container .sortable-placeholder)— a:not()containing a descendant combinator. In engines without full Selectors Level 4:not()support, the entire rule is dropped, leaving the placeholder unstyled (an invisible gap). Even when applied, it was a faint 1px light-grey outline with no fill.#dashboard-widgets-wrapusedoverflow: hidden(only to contain floated columns), which clipped the absolutely-positioned sortable helper when it left the wrap bounds during scroll-drags, and could be picked up as the dragscrollParent, skewing placeholder position math.top: 50%) inside a full-height empty column, pushing it far down the page.Changes
src/js/_enqueues/admin/postbox.js— On drag start, equalize all Dashboard.meta-box-sortablesdrop areas to the tallest column's height (cleared on stop), so a widget can be dropped anywhere in any column.refreshPositions()(already called instart) re-caches the new heights for jQuery UI's intersection checks. Scoped to#dashboard-widgetsso the post-edit screen is unaffected.src/wp-admin/css/common.css— Made the.sortable-placeholderreliably visible (2px dashed theme color + subtle fill) and split the empty-container exception into its own simple rule instead of a fragile:not()with a descendant combinator, so the placeholder styles can't be silently dropped.src/wp-admin/css/dashboard.css— Replacedoverflow: hiddenon#dashboard-widgets-wrapwithdisplay: flow-root(contains the floated columns without clipping the drag helper), and top-aligned the empty-column "Drag boxes here" hint instead of vertically centering it.Trac ticket: https://core.trac.wordpress.org/ticket/65151
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.8
Used for: Diagnosing the root causes and drafting the CSS/JS changes. All changes were reviewed, tested in a local develop build, and edited by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.