Repository navigation
Description
Subject
RTL drag-and-drop with acceptWidgets renders the drop placeholder and widget at mirrored X coordinates
Description
When using GridStack.js with rtl: true, drag-and-drop behavior with acceptWidgets does not work as expected. The gray drop placeholder is rendered at the opposite horizontal position, and the widget is dropped at mirrored X coordinates.
The issue occurs regardless of whether the parent application uses LTR or RTL direction. The problem persists whenever GridStack's RTL option is enabled.
In LTR mode, the drag-and-drop behavior works correctly: when a draggable item is picked up and moved into the grid boundaries, the gray drop placeholder appears at the expected position and follows the mouse cursor. When the item is dropped, it is placed at the correct X and Y coordinates.
However, when rtl: true is enabled, the behavior is incorrect:
- When a draggable item is moved into the grid boundaries, the gray drop placeholder appears at a mirrored horizontal position.
- As the mouse moves horizontally, the placeholder moves in the opposite direction.
- When the item is dropped, it is placed at mirrored X coordinates instead of the expected position.
Environment
- GridStack.js version: 14.1.1
- OS: macOS 27.2.1
- Browser: Google Chrome 157
Steps to reproduce
- Open the following StackBlitz demo:
https://stackblitz.com/edit/gridstack-demo-bb5xg61w - Configure GridStack with
rtl: true. - The parent application can use either LTR or RTL direction; the issue persists in both cases.
- Start dragging an external widget configured to be accepted by the grid through
acceptWidgets. - Move the widget into the grid boundaries and observe the gray drop placeholder.
- Move the mouse horizontally and observe how the placeholder position changes.
- Drop the widget and observe its final X and Y coordinates.
- Repeat with
rtl: falseto compare the behavior. - Change the Gridstack.js version to 12.2.2, it works as expected.
Working demo: https://stackblitz.com/edit/gridstack-demo-bb5xg61w
Screen.Recording.2026-11-23.at.16.22.34.mov
Video: Attached screen recording demonstrating the issue.
Expected behavior
When rtl: true is enabled, the gray drop placeholder should appear at the correct position relative to the mouse cursor and move consistently with the cursor during dragging.
When the widget is dropped, it should be placed at the intended grid coordinates without incorrectly mirroring the X coordinate.
The drag-and-drop behavior should correctly respect GridStack's RTL configuration, independently of the parent application's text direction.
Activity
jjohnnystwsss commentedon Nov 23, 2026
I'd like to pick this up. In the current source,
DDDraggable.ui()already reports internal RTL drag positions from the container's right edge, while theacceptWidgetsdrag handler measures the helper from the target grid's left edge before passing it to the shared movement code. That looks like the coordinate boundary to investigate; I haven't run the browser reproduction yet.I'll first reproduce the 14.1.1 behavior and compare it with the reported 12.2.2 control, then make external drags use the target grid's logical coordinates without changing the helper's cursor offset or the layout engine's coordinate convention.
The regression should exercise real browser dragging and check both the placeholder position and the final saved x/y, with LTR/RTL parent containers, single- and multi-column widgets, and transfers between grids of different directions. Existing internal drags and ordinary LTR drops should remain covered too.
Codex is assisting with the investigation, implementation and tests. I'll include the actual before/after results in the PR.