em
em copied to clipboard
Refactor dragAndDropThought: replace mouseUp with hold parameter and add dragAndHoldThought helper
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?: booleantohold?: booleanindragAndDropThought - Inverted the logic: now defaults to completing the drop (
mouse.up()) unlesshold: true - Updated parameter documentation for clarity
2. Add new dragAndHoldThought helper
- New function that calls
dragAndDropThoughtwithhold: true - Makes the intent explicit when you want to hold the drag without completing it
- Same signature as
dragAndDropThoughtbut without theholdparameter
3. Update existing usage
- Removed
mouseUp: truefrom test calls (now default behavior) - Changed
mouseUp: falseto usedragAndHoldThought()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.