Skip to content

Commit

Permalink
fix(title-bar): component remains displayed after player reset
Browse files Browse the repository at this point in the history
When `player.reset` is called the `titleBar` component is not reset.

- Sets the properties `title` and `description` to `undefined` when `player.titleBar.update` is called so that the component is properly reset.
  • Loading branch information
amtins committed Nov 29, 2023
1 parent 7972c23 commit 6d128fb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3607,6 +3607,13 @@ class Player extends Component {

this.error(null);

if (this.titleBar) {
this.titleBar.update({
title: undefined,
description: undefined
});
}

if (isEvented(this)) {
this.trigger('playerreset');
}
Expand Down
21 changes: 21 additions & 0 deletions test/unit/reset-ui.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,24 @@ QUnit.test('Calling reset player method should reset both error display and play

player.dispose();
});

QUnit.test('Calling reset player method should reset title bar', function(assert) {
const player = TestHelpers.makePlayer();

player.titleBar.update({
title: 'Title',
description: 'Description'
});

assert.notOk(player.titleBar.hasClass('vjs-hidden'), 'TitleBar is visible if not empty');
assert.strictEqual(player.titleBar.els.title.textContent, 'Title', 'TitleBar title element has content');
assert.strictEqual(player.titleBar.els.description.textContent, 'Description', 'TitleBar description element has content');

player.reset();

assert.ok(player.titleBar.hasClass('vjs-hidden'), 'TitleBar is not visible if empty');
assert.strictEqual(player.titleBar.els.title.textContent, '', 'TitleBar title element has no content');
assert.strictEqual(player.titleBar.els.description.textContent, '', 'TitleBar description element has no content');

player.dispose();
});

0 comments on commit 6d128fb

Please sign in to comment.