Skip to content

Fix waveform Alt+drag producing overlapping subtitles on release#11395

Merged
niksedk merged 1 commit into
SubtitleEdit:mainfrom
mjuhasz:fix/waveform-alt-drag-overlap
Jun 4, 2026
Merged

Fix waveform Alt+drag producing overlapping subtitles on release#11395
niksedk merged 1 commit into
SubtitleEdit:mainfrom
mjuhasz:fix/waveform-alt-drag-overlap

Conversation

@mjuhasz
Copy link
Copy Markdown
Contributor

@mjuhasz mjuhasz commented Jun 4, 2026

Summary

  • When holding Option (Alt) and making a very short drag on a subtitle's left edge, Avalonia fires both PointerReleased and Tapped (movement was below the ~3px tap threshold)
  • The OnTapped Alt branch was setting the grid-selected subtitle's StartTime to the tap position — which could be a different subtitle than the one being dragged, causing it to jump forward and overlap the dragged subtitle
  • Fix: add a _preventNextTap flag that is set in OnPointerReleased whenever a drag mode was active, and checked at the top of OnTapped to bail out early

Details

The waveform's ResizeLeftAnd mode (Option+drag left edge) correctly moves both subtitle N's start and subtitle N-1's end backward, preserving the gap. The bug manifested when the drag was short enough for Avalonia to also raise a Tapped event:

  1. OnPointerReleased clears drag state — both subtitles correctly positioned
  2. OnTapped fires with _isAltDown = true
  3. firstSelected = AllSelectedParagraphs.FirstOrDefault() — the grid-selected subtitle, potentially N-1
  4. firstSelected.StartTime = tap_position (≈ N's left edge) triggers OnStartTimeChanged, moving N-1's entire block forward to overlap N

The bug was intermittent because it only occurred when the drag fell below the tap threshold (~3 logical pixels) and a different subtitle was selected in the grid.

Alt+tap on empty waveform space (New mode) is unaffected by this change.

Testing

I tested the following scenarios:

  • Hold Option and drag a subtitle's left edge backward — confirm the previous subtitle shortens correctly and does not jump forward on release
  • Reproduce with the grid-selected subtitle being the one before the dragged subtitle — confirm the previous (selected) subtitle shortens correctly and does not jump forward on release
  • Alt+click on empty waveform space — confirm the selected subtitle's start time still moves to the clicked position

Video of the bug

There are 3 subtitles on the wave form. I'm Option(Alt)-dragging the left edge of the thirds one and upon mouse release the second subtitle start time gets set to where the pointer is at that time, resulting in the second subtitle moving to the right, on top of the third one.

Option-Drag.mov

When Option is held and the user makes a very short drag on a subtitle's
left edge (movement below Avalonia's ~3px tap threshold), both
PointerReleased and Tapped fire. The OnTapped Alt branch was then setting
the grid-selected subtitle's StartTime to the tap position — which could
be a different subtitle than the one being dragged, causing it to jump
forward and overlap.

Fix by tracking a _preventNextTap flag: set it in OnPointerReleased
whenever a drag mode was active, and bail out at the top of OnTapped
if the flag is set. Alt+tap on empty waveform space (New mode) is
unaffected.
@niksedk niksedk merged commit c1a1ab0 into SubtitleEdit:main Jun 4, 2026
2 checks passed
@mjuhasz mjuhasz deleted the fix/waveform-alt-drag-overlap branch June 4, 2026 19:52
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