Fix waveform Alt+drag producing overlapping subtitles on release#11395
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PointerReleasedandTapped(movement was below the ~3px tap threshold)OnTappedAlt branch was setting the grid-selected subtitle'sStartTimeto the tap position — which could be a different subtitle than the one being dragged, causing it to jump forward and overlap the dragged subtitle_preventNextTapflag that is set inOnPointerReleasedwhenever a drag mode was active, and checked at the top ofOnTappedto bail out earlyDetails
The waveform's
ResizeLeftAndmode (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 aTappedevent:OnPointerReleasedclears drag state — both subtitles correctly positionedOnTappedfires with_isAltDown = truefirstSelected = AllSelectedParagraphs.FirstOrDefault()— the grid-selected subtitle, potentially N-1firstSelected.StartTime = tap_position(≈ N's left edge) triggersOnStartTimeChanged, moving N-1's entire block forward to overlap NThe 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 (
Newmode) is unaffected by this change.Testing
I tested the following scenarios:
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