1
0
mirror of https://github.com/videojs/video.js.git synced 2025-04-07 07:19:54 +02:00

fix: Don't hide menus with one item and a title (#7215)

Menus with one item are hidden if they have a title, because adding the title increments the hide threshold, but the title is not counted as an item. e.g. the chapters menu if there is a single chapter.
This commit is contained in:
mister-ben 2021-05-11 00:28:31 +02:00 committed by GitHub
parent 90f3e39b33
commit d4a08deb10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -120,8 +120,6 @@ class MenuButton extends Component {
tabIndex: -1
});
this.hideThreshold_ += 1;
const titleComponent = new Component(this.player_, {el: titleEl});
menu.addItem(titleComponent);

View File

@ -43,6 +43,24 @@ QUnit.test('should place title list item into ul', function(assert) {
player.dispose();
});
QUnit.test('should not include menu title in hide threshold', function(assert) {
const player = TestHelpers.makePlayer();
const menuButton = new MenuButton(player, {
title: 'testTitle'
});
assert.strictEqual(menuButton.hideThreshold_, 0, 'title should not increment hideThreshold_');
menuButton.createItems = () => [new MenuItem(player, { label: 'menu-item1' })];
menuButton.update();
assert.strictEqual(menuButton.hasClass('vjs-hidden'), false, 'menu button with single (non-title) item is not hidden');
menuButton.dispose();
player.dispose();
});
QUnit.test('clicking should display the menu', function(assert) {
assert.expect(6);