Skip to content

Fix card drag handle layout shift on hover#637

Merged
Chris0Jeky merged 2 commits intomainfrom
fix/621-card-drag-layout-shift
Mar 31, 2026
Merged

Fix card drag handle layout shift on hover#637
Chris0Jeky merged 2 commits intomainfrom
fix/621-card-drag-layout-shift

Conversation

@Chris0Jeky
Copy link
Copy Markdown
Owner

Summary

  • Replace width: 0; overflow: hidden with visibility: hidden; opacity: 0 on the drag label so it reserves its horizontal space and eliminates layout shift on hover
  • Remove negative margins (-0.5rem) on the card action bar that caused visual jump when the bar appeared
  • All existing CardItem unit tests pass (1444 total)

Closes #621

Test plan

  • Hover over a board card and verify the drag handle area does not shift/jump
  • Verify "Drag card" label fades in smoothly on drag handle hover without changing card width
  • Verify drag-and-drop still works correctly
  • Verify card action bar (drag handle + move button) is visually stable across hover/idle states

Replace width:0/overflow:hidden with visibility:hidden/opacity:0 for
the drag label so it reserves space without causing layout shift.
Remove negative margins on the action bar that caused visual jump.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@Chris0Jeky
Copy link
Copy Markdown
Owner Author

Self-review

Changes reviewed:

  1. Drag label: width:0/overflow:hidden -> visibility:hidden/opacity:0 -- Correct fix. The label now reserves its space in the flex layout at all times, so hovering only changes visibility/opacity without reflowing. The transition: opacity var(--td-transition-fast) on .td-board-card__drag-label (line 387) still applies, so the fade-in animation is preserved.

  2. Action bar: negative margins removed -- The old margin: -0.5rem -0.5rem var(--td-space-2) -0.5rem pulled the action bar outside the card padding, which could cause visual shift when combined with hover state changes. Now uses only margin-bottom for spacing. This does change the visual positioning slightly -- the action bar buttons will no longer extend into the card padding area. This is intentional: it trades a minor spacing change for stable layout.

Potential concerns:

  • The drag label now always takes up horizontal space (even when invisible). For narrow columns this adds ~60px of reserved width inside the drag handle button. Since the handle uses flex-1 and the label text is small ("Drag card"), this should be fine in practice but worth verifying visually on narrow boards.
  • Removing negative margins shifts the action bar inward by 0.5rem on each side. The card padding (var(--td-space-4) = 1rem) is generous enough that this should look natural.

Verdict: Changes are correct, minimal, and targeted. All unit tests pass. No functional regressions expected -- drag handle still works via the data-action="drag-card-handle" attribute which is unchanged.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the CardItem.vue component to simplify margin styling and prevent layout shifts by using visibility and opacity for the drag label instead of width manipulation. A review comment suggests improving accessibility by ensuring the label is also displayed when the drag handle receives keyboard focus via the :focus-visible pseudo-class.

Comment on lines 398 to 401
.td-card-drag-handle:hover .td-board-card__drag-label--hidden {
visibility: visible;
opacity: 1;
width: auto;
overflow: visible;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For better accessibility, the 'Drag card' label should also appear when the drag handle button receives keyboard focus, not just on hover. You can achieve this by adding a :focus-visible state to the selector. This will improve the experience for keyboard-only users and is consistent with the use of :focus-visible for focus styling elsewhere in the project.

.td-card-drag-handle:hover .td-board-card__drag-label--hidden,
.td-card-drag-handle:focus-visible .td-board-card__drag-label--hidden {
  visibility: visible;
  opacity: 1;
}

The E2E test asserts the drag handle width is > 75% of card width.
The original negative left/right margins extend the action bar to
the card edges. Keep those, only remove the top negative margin
that caused the layout shift on hover.
@Chris0Jeky Chris0Jeky merged commit ad27271 into main Mar 31, 2026
22 checks passed
@github-project-automation github-project-automation bot moved this from Pending to Done in Taskdeck Execution Mar 31, 2026
@Chris0Jeky Chris0Jeky deleted the fix/621-card-drag-layout-shift branch March 31, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

UX-21: Card drag handle — eliminate layout shift on hover

1 participant