Skip to content

Conversation

@ds300
Copy link
Collaborator

@ds300 ds300 commented Oct 30, 2025

had to add a drag threshold thingy to make this not annoying af

Change type

  • other

Note

Enables dragging groups in the sidebar to reorder them, adds a drag-start threshold and cursor indicator, and introduces shared types and hooks to support the behavior.

  • Sidebar UX:
    • Group reordering: Make TlaSidebarGroupItem draggable and reorderable with a global reorder cursor shown after a drag threshold (hasDragStarted).
    • Visual feedback: Dim dragging items via data-is-dragging and new CSS; show drop cursor only when dragging has begun.
  • Hooks & Logic:
    • Implement detectGroupOperation and executeGroupOperations to compute insert position and update group order (fractional indexing via updateOwnGroupUser).
    • Track drag elements for groups (groupItems) and add a small movement threshold before activating drag.
    • New useIsDragging hook; replace inline dragging checks in file/group components.
  • State & Types:
    • Extend DragState with hasDragStarted and support for DragGroupOperation.
    • Add shared DragGroupOperation type and adjust reorder indicator constants/names.
  • Misc:
    • Gate various drop/reorder UI states on hasDragStarted (e.g., recent files, reorder cursor).

Written by Cursor Bugbot for commit dbb8bd1. This will update automatically on new commits. Configure here.

@ds300 ds300 requested a review from MitjaBezensek October 30, 2025 12:19
@vercel
Copy link

vercel bot commented Oct 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
analytics Ready Ready Preview Oct 31, 2025 3:11pm
examples Ready Ready Preview Oct 31, 2025 3:11pm
4 Skipped Deployments
Project Deployment Preview Updated (UTC)
tldraw-docs Ignored Ignored Preview Oct 31, 2025 3:11pm
chat-template Skipped Skipped Oct 31, 2025 3:11pm
tldraw-shader Skipped Skipped Oct 31, 2025 3:11pm
workflow-template Skipped Skipped Oct 31, 2025 3:11pm

Copy link
Contributor

@MitjaBezensek MitjaBezensek left a comment

Choose a reason for hiding this comment

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

Don't think we should show the separator here, it's a noop action that doesn't change anything:

CleanShot.2025-11-03.at.13.44.05.mp4

When dragging a group that is between groups the separator shows in a strange spot:

CleanShot.2025-11-03.at.13.43.28.mp4

On mobile it opens the context menu and then shows the separator on top of it:

ScreenRecording_11-03-2025.13-48-47_1.MP4

}
}

async function executeGroupOperations(app: TldrawApp, groupId: string, operation: any) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
async function executeGroupOperations(app: TldrawApp, groupId: string, operation: any) {
async function executeGroupOperations(app: TldrawApp, groupId: string, operation: DragGroupOperation) {

newIndex = getIndexBetween(beforeGroup?.index, afterGroup?.index)
}

await app.z.mutate.updateOwnGroupUser({ groupId, index: newIndex })
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
await app.z.mutate.updateOwnGroupUser({ groupId, index: newIndex })
app.z.mutate.updateOwnGroupUser({ groupId, index: newIndex })

@ds300
Copy link
Collaborator Author

ds300 commented Nov 4, 2025

Don't think we should show the separator here, it's a noop action that doesn't change anything:

tried and discussed this quite extensively with Mai Linh, we decided that it was better overall to show the indicator even if it's a noop. without it the lack of hints for what the interaction involves can feel confusing, especially because if the groups are open it can take a looong while for the mouse to move to a position where the drag would have an effect.

@ds300
Copy link
Collaborator Author

ds300 commented Nov 4, 2025

i'll fix the other things, good catches!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants