Skip to content

Commit 161a09c

Browse files
authored
fix(title-bar): component remains displayed after player reset (#8481)
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.
1 parent 6d8af0c commit 161a09c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/js/player.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,6 +3607,13 @@ class Player extends Component {
36073607

36083608
this.error(null);
36093609

3610+
if (this.titleBar) {
3611+
this.titleBar.update({
3612+
title: undefined,
3613+
description: undefined
3614+
});
3615+
}
3616+
36103617
if (isEvented(this)) {
36113618
this.trigger('playerreset');
36123619
}

test/unit/reset-ui.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,24 @@ QUnit.test('Calling reset player method should reset both error display and play
160160

161161
player.dispose();
162162
});
163+
164+
QUnit.test('Calling reset player method should reset title bar', function(assert) {
165+
const player = TestHelpers.makePlayer();
166+
167+
player.titleBar.update({
168+
title: 'Title',
169+
description: 'Description'
170+
});
171+
172+
assert.notOk(player.titleBar.hasClass('vjs-hidden'), 'TitleBar is visible if not empty');
173+
assert.strictEqual(player.titleBar.els.title.textContent, 'Title', 'TitleBar title element has content');
174+
assert.strictEqual(player.titleBar.els.description.textContent, 'Description', 'TitleBar description element has content');
175+
176+
player.reset();
177+
178+
assert.ok(player.titleBar.hasClass('vjs-hidden'), 'TitleBar is not visible if empty');
179+
assert.strictEqual(player.titleBar.els.title.textContent, '', 'TitleBar title element has no content');
180+
assert.strictEqual(player.titleBar.els.description.textContent, '', 'TitleBar description element has no content');
181+
182+
player.dispose();
183+
});

0 commit comments

Comments
 (0)