em icon indicating copy to clipboard operation
em copied to clipboard

Refactor dragAndDropThought: replace mouseUp with hold parameter and add dragAndHoldThought helper

Open Copilot opened this issue 8 months ago • 0 comments

The mouseUp parameter in the dragAndDropThought puppeteer helper was confusing because it defaulted to falsey but most use cases expected the drag to complete (mouse up). This PR splits the functionality into two clear helpers and improves the API design.

Changes

1. Replace mouseUp with hold parameter

  • Changed mouseUp?: boolean to hold?: boolean in dragAndDropThought
  • Inverted the logic: now defaults to completing the drop (mouse.up()) unless hold: true
  • Updated parameter documentation for clarity

2. Add new dragAndHoldThought helper

  • New function that calls dragAndDropThought with hold: true
  • Makes the intent explicit when you want to hold the drag without completing it
  • Same signature as dragAndDropThought but without the hold parameter

3. Update existing usage

  • Removed mouseUp: true from test calls (now default behavior)
  • Changed mouseUp: false to use dragAndHoldThought() for clarity
  • Updated imports to include the new helper

Before/After API

Before:

// Confusing - mouseUp: true was needed for the common case
await dragAndDropThought('a', 'b', { position: 'after', mouseUp: true })

// mouseUp: false to hold the drag
await dragAndDropThought('a', null, { position: 'none', mouseUp: false })

After:

// Clear - completes the drop by default
await dragAndDropThought('a', 'b', { position: 'after' })

// Explicit intent to hold the drag
await dragAndHoldThought('a', null, { position: 'none' })

The new API follows the principle of making the common case (completing the drop) the default, while providing a clear alternative for holding the drag.

Fixes #3030.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Jun 13 '25 09:06 Copilot