Skip to content

feat(data-weaver): Card dragging and content select - #461

Open
pablonoel wants to merge 9 commits into
datacommonsorg:mainfrom
pablonoel:ui-text_select
Open

feat(data-weaver): Card dragging and content select#461
pablonoel wants to merge 9 commits into
datacommonsorg:mainfrom
pablonoel:ui-text_select

Conversation

@pablonoel

@pablonoel pablonoel commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Overview

Restrict card dragging to the actions bar, only once selected, privileging the text selection of the content inside the cards

Changes Made

Screenshot 2026-09-03 at 1 28 22 PM

Previously, pressing anywhere on a card (unselected) would fall through to tldraw's default select tool, which selects and starts dragging in one gesture. Now the first press only selects the card and allows the content "text selection" — dragging is only available afterward, and only from the actions bar.

Card intercepts pointerdown while unselected, selects itself via editor.select(), and stops propagation so tldraw's native select+drag gesture never fires (left-click only, so right-click/context-menu still works).

The actions bar's drag handle (startDragging) is now gated to only run when the card is already selected.
Add a drag indicator to the actions bar

A drag_indicator icon (new IconDragIndicator in primitives/icons) is shown at the right edge of the actions bar as a visual affordance that the bar is draggable. It's decorative only (not a button, no click handling) — sized/colored to match the other action icons and vertically centered against --actions-height.

Testing Done

Describe the steps you took to test these changes (please also list commands ran if possible).

  • Unit tests passed
  • Integration tests passed
  • Manual verification

Checklist

  • I have followed the style guidelines of this project.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings.

Note: Only Maintainers can approve and merge PRs. Expected initial review time: 3 business days.

Import useEditor and call editor.select(id) on pointerdown when the card is unselected, stopping propagation so the initial press only selects (doesn't begin a drag). Make the actions bar start dragging only when the card is already selected. Also adjust the TLShapeId import to a named type import. This prevents tldraw's default select+drag gesture from starting on the first press and provides a clearer select-then-drag interaction.
Introduce a reusable IconDragIndicator SVG and render it inside CardBase actions. Update card styles to position the actions container relative and add .drag-indicator rules (size, position, color, opacity, responsive sizing). Changes: added drag_indicator.tsx, updated base.tsx to import and render the icon, and enhanced base.module.scss to style and place the indicator.

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

Copy link
Copy Markdown
Contributor

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 introduces a drag indicator icon to the CardBase component and updates its selection and dragging behavior to prevent immediate dragging on unselected cards. The review feedback suggests restricting the card selection trigger to primary clicks to preserve context menus, using an interface instead of inline types for the icon's props, and replacing a magic percentage in the CSS with a dynamic calculation for better vertical alignment.

Comment thread dataweaver/apps/web/src/components/elements/card/base.tsx
Comment thread dataweaver/apps/web/src/components/elements/card/base.module.scss Outdated
@pablonoel
pablonoel marked this pull request as ready for review September 3, 2026 17:39
@pablonoel pablonoel changed the title UI text select feat(data-weaver): Card dragging and content select Sep 3, 2026

@nick-nlb nick-nlb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One of the commits connected to this PR has co-pilot as a coauthor (and so the PR does not pass CLA requirements).

Can we rebase/rewrite the commit to no longer include the co-authorship?

Add a guard in CardBase onPointerDown to ignore non-left mouse buttons (event.button !== 0), preventing right/middle clicks from triggering selection. Update .drag-indicator top to calc(var(--actions-height) / 2) to center it relative to the actions area instead of using a fixed 40% value.

@nick-nlb nick-nlb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you very much Pablo! Some comments inline.

className={s.container}
data-is-loading={isLoading}
data-selection={selection}
// While unselected, a pointerdown anywhere on the card (content or

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The behavior now in the "hand" (pan) mode is different. Is this intentional?

Previously, selecting cards or selecting text on cards was restricted to pointer mode, and pan mode would pan regardless. The older behavior feels natural to me.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is partially addressed, but when a card is single selected, pan mode no longer pans still. I could be persuaded on this, but this behavior feels inconsistent.

I.e., in pointer mode, select a card. Switch to pan mode (hand). Non selected cards behave differently than the single selected card (and there is no way to select or deselect a card in this mode - by design).

I think this would be resolved by having the single selected card still just behave like the others in pan mode.

Comment thread dataweaver/apps/web/src/components/elements/card/base.tsx
Comment thread dataweaver/apps/web/src/components/elements/card/base.module.scss Outdated
Comment thread dataweaver/apps/web/src/components/elements/card/base.module.scss Outdated
Comment thread dataweaver/apps/web/src/components/elements/card/base.module.scss Outdated
Comment thread dataweaver/apps/web/src/components/elements/card/base.tsx
Rename and restyle the card drag indicator to .icon-drag-indicator and add a muted action-content token. Update SCSS (fix/comment about Safari ghosting and use card-action-content-muted for the icon). Tighten CardBase pointer handling: don't intercept pointerdown when modifier keys are held or when the current tool isn't 'select' so pan/hand and multi-select work as expected. Also clarify comments about when events are allowed through for selection/drag behavior.
@nick-nlb
nick-nlb self-requested a review September 4, 2026 18:56
Comment thread dataweaver/apps/web/src/components/elements/card/base.tsx Outdated
Include altKey in the modifier check in CardBase pointer handler so alt+click/drag
Selected cards were always stopping pointerdown propagation, even when the active tool was not select. This prevented pan interactions from working over cards. The fix only blocks propagation for the select tool, allowing hand/tool interactions to continue normally.
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.

2 participants