From 781ca8de91fd0bf65e9982f38eeddd499a2547ed Mon Sep 17 00:00:00 2001 From: Charlie Gracie Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] fix: Set finished=false in goto instead of handleProgressClick (#1198) * Reset the finished flag in goto If the player finishes a replaying a video the `finished` boolean is set to true. This allows the video to be restarted at the beginning if the controller is toggled again. If a user clicks on the progress bar the `finished` boolean is reset so if the `toggle` API is called it starts at the right place. If a user programatically calls `goto` which is the underlying API that handling the progress click calls the next invocation of `toggle` will start the video at the beginning instead of the proper location. * Create controller-finish-flag.md * Update controller-finish-flag.md --- .changeset/controller-finish-flag.md | 6 ++++++ packages/rrweb-player/src/Controller.svelte | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/controller-finish-flag.md diff --git a/.changeset/controller-finish-flag.md b/.changeset/controller-finish-flag.md new file mode 100644 index 00000000..567e5db4 --- /dev/null +++ b/.changeset/controller-finish-flag.md @@ -0,0 +1,6 @@ +--- +'rrweb-player': patch +'rrweb': patch +--- + +Reset the finished flag in Controller `goto` instead of `handleProgressClick` so that it is properly handled if `goto` is called directly. diff --git a/packages/rrweb-player/src/Controller.svelte b/packages/rrweb-player/src/Controller.svelte index 57d32313..5a352e6d 100644 --- a/packages/rrweb-player/src/Controller.svelte +++ b/packages/rrweb-player/src/Controller.svelte @@ -208,6 +208,7 @@ export const goto = (timeOffset: number, play?: boolean) => { currentTime = timeOffset; pauseAt = false; + finished = false; const resumePlaying = typeof play === 'boolean' ? play : playerState === 'playing'; if (resumePlaying) { @@ -250,7 +251,6 @@ percent = 1; } const timeOffset = meta.totalTime * percent; - finished = false; goto(timeOffset); };