Skip to content

Commit cfc0a06

Browse files
GitHub Copilotclaude
andcommitted
Fix race condition with autoCenter/autoScroll during loadBlob (#4187)
Fixed a race condition where autoScroll and autoCenter would sometimes cause the scroll position to jump to the beginning when loading a blob. The issue occurred when renderProgress was called while the audio data was still being loaded/decoded (duration temporarily 0 or invalid), which triggered scrollIntoView to scroll to position 0. The fix adds a guard to only call scrollIntoView when valid audio data exists with a duration > 0, preventing the race condition. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e37b915 commit cfc0a06

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ cypress/**/__diff_output__/
1010
.env
1111
coverage/
1212
eslint_report.json
13+
.beads/

src/renderer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@ class Renderer extends EventEmitter<RendererEvents> {
725725
? `translateX(-${progress * this.options.cursorWidth}px)`
726726
: ''
727727

728-
if (this.isScrollable && this.options.autoScroll) {
728+
// Only scroll if we have valid audio data to prevent race conditions during loading
729+
if (this.isScrollable && this.options.autoScroll && this.audioData && this.audioData.duration > 0) {
729730
this.scrollIntoView(progress, isPlaying)
730731
}
731732
}

0 commit comments

Comments
 (0)