Skip to content

Commit

Permalink
fix(audio-player): stops playing when removed from DOM (VIV-1967) (#1880
Browse files Browse the repository at this point in the history
)
  • Loading branch information
YonatanKra authored Aug 13, 2024
1 parent 88396d0 commit 12355d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libs/components/src/lib/audio-player/audio-player.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,15 @@ describe('vwc-audio-player', () => {

expect(playSpy).toHaveBeenCalledTimes(1);
});

it('should stop playing on disconnectedCallback', async () => {
setCurrentTimeAndDuration(10, 100);
element.play();
await elementUpdated(element);

element.remove();
expect(element.paused).toBe(true);
});
});

describe('pause()', () => {
Expand Down
1 change: 1 addition & 0 deletions libs/components/src/lib/audio-player/audio-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export class AudioPlayer extends FoundationElement {
override disconnectedCallback() {
super.disconnectedCallback();
this.#setSliderInteractionListeners(false);
this.pause();
}

play() {
Expand Down

0 comments on commit 12355d3

Please sign in to comment.