fix(content-manager): make drag-and-drop drop indicator match component height by itsmejay80 · Pull Request #26094 · strapi/strapi · GitHub
Skip to content

fix(content-manager): make drag-and-drop drop indicator match component height#26094

Open
itsmejay80 wants to merge 1 commit intostrapi:developfrom
itsmejay80:fix/dnd-component-drop-indicator-26087
Open

fix(content-manager): make drag-and-drop drop indicator match component height#26094
itsmejay80 wants to merge 1 commit intostrapi:developfrom
itsmejay80:fix/dnd-component-drop-indicator-26087

Conversation

@itsmejay80
Copy link
Copy Markdown
Contributor

@itsmejay80 itsmejay80 commented Apr 22, 2026

Summary

  • Fixes Drag and drop component: Hard to see where the component is being moved to on the page #26087: when dragging a component in a Dynamic Zone or Repeatable component, the drop-target placeholder shrank to a small padded box, making it hard to see where the item would land — especially when the source component was expanded or tall.
  • Captures the component's rendered height via a layout effect before it's replaced by the Preview placeholder, and applies it as the placeholder height so the drop indicator fills the same vertical space the dragged component occupied.
  • Aligns the dashed outline colour with the Relations list placeholder (primary600) and adds a matching border-radius for visual consistency across drag-and-drop surfaces.

Before / After

  • Before: placeholder is a small dashed box (~48px), list layout collapses and jumps while dragging — drop position unclear.
  • After: placeholder matches the dragged component's previous height, drop position is visible throughout the drag.

Files changed

  • packages/core/content-manager/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.tsx
  • packages/core/content-manager/admin/src/pages/EditView/components/FormInputs/Component/Repeatable.tsx

Why a layout effect (and not height: 100%)

The Relations list (Relations.tsx:1368) already uses height: calc(100% - gutter) but only works there because rows have a fixed height from react-window virtualization. Dynamic-zone and repeatable rows have variable heights and no height-constrained parent, so the placeholder must carry the height explicitly — captured from boxRef.current.offsetHeight in a useLayoutEffect while the element is still mounted and non-dragging.

Test plan

  • In an entry with a Dynamic Zone containing several components, drag a collapsed component across siblings — placeholder height matches the collapsed accordion.
  • Repeat with an expanded component — placeholder now spans the full expanded height, no list collapse during drag.
  • Same checks inside a Repeatable component.
  • Relations drag-and-drop is unaffected (not touched).
  • Keyboard drag-and-drop (Space + Arrow keys) still reorders items.
  • Existing DynamicZone and Repeatable tests still pass.

…nt height

Closes strapi#26087

When dragging a dynamic-zone or repeatable component, the drop-target
placeholder collapsed to a small padded box regardless of the source
component's size. On lists with tall/expanded components the preview
was hard to locate, making it unclear where the item would land.

Capture the component's height via a layout effect before it is
replaced by the Preview and apply it as the placeholder height so the
drop indicator fills the same vertical space. Also align the dashed
outline colour with the Relations placeholder (primary600) and add a
matching border radius for visual consistency.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 22, 2026 13:52
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 22, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a UX issue in the content-manager EditView drag-and-drop experience by making the drop-target placeholder match the dragged component’s rendered height (especially important for expanded/variable-height components).

Changes:

  • Capture a component’s rendered height before it’s replaced by the drag “Preview” placeholder (Dynamic Zone + Repeatable).
  • Apply the captured height to the placeholder so the list doesn’t collapse/jump during drag.
  • Align placeholder styling (dashed outline color + border radius) with other drag-and-drop surfaces.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
packages/core/content-manager/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.tsx Measure and apply Dynamic Zone item height to the drag placeholder; update placeholder styling.
packages/core/content-manager/admin/src/pages/EditView/components/FormInputs/Component/Repeatable.tsx Measure and apply Repeatable component item height to the drag placeholder; update placeholder styling and simplify placeholder element.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +104 to +109
React.useLayoutEffect(() => {
if (!isDragging && boxRef.current) {
previewHeightRef.current = (boxRef.current as HTMLElement).offsetHeight;
}
});

padding: ${({ theme }) => theme.spaces[6]};
border-radius: ${({ theme }) => theme.borderRadius};
${({ $height, theme }) =>
$height !== undefined ? `height: ${$height}px;` : `padding: ${theme.spaces[6]};`}
Comment on lines +101 to +105
// Capture the component's height before it's replaced by the Preview so the
// drop indicator fills the same space and the drop position stays visible.
const previewHeightRef = React.useRef<number | undefined>(undefined);
React.useLayoutEffect(() => {
if (!isDragging && boxRef.current) {
Comment on lines +473 to +478
React.useLayoutEffect(() => {
if (!isDragging && boxRef.current) {
previewHeightRef.current = (boxRef.current as HTMLElement).offsetHeight;
}
});

outline-offset: -1px;
border-radius: ${({ theme }) => theme.borderRadius};
${({ $height, theme }) =>
$height !== undefined ? `height: ${$height}px;` : `padding: ${theme.spaces[6]};`}
@mathildeleg
Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: fix This PR is fixing a bug source: core:content-manager Source is core/content-manager package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drag and drop component: Hard to see where the component is being moved to on the page

3 participants