fix: drag-to-select now works reliably without Shift key

Fixed async state update issue where selections were being cleared
immediately after creation. The mouseUp handler now checks drag
distance directly instead of relying on async state, ensuring
selections persist correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-18 14:28:09 +01:00
parent 1dc0604635
commit 166385d29a

View File

@@ -274,8 +274,15 @@ export function Track({
const x = e.clientX - rect.left;
const clickTime = (x / rect.width) * duration;
// Check if user actually dragged (check distance directly, not state)
const didDrag = dragStartPos
? Math.sqrt(
Math.pow(e.clientX - dragStartPos.x, 2) + Math.pow(e.clientY - dragStartPos.y, 2)
) > 3
: false;
// If user didn't drag (just clicked), clear selection and seek
if (!isSelectingByDrag) {
if (!didDrag) {
onSelectionChange?.(null);
if (onSeek) {
onSeek(clickTime);