From d0cf139384ada22f4b8d48d6696e37b4e64ddc43 Mon Sep 17 00:00:00 2001 From: mister-ben <1676039+mister-ben@users.noreply.github.com> Date: Thu, 14 Nov 2024 09:21:07 +0100 Subject: [PATCH 1/4] fix: Fix Escape handling in menus (#8916) Fixes that Escape being pressed isn't closing menus due to incorrect `event.key` name. --- src/js/menu/menu-button.js | 6 +++--- test/unit/menu.test.js | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/js/menu/menu-button.js b/src/js/menu/menu-button.js index 73fecada3..7672779bd 100644 --- a/src/js/menu/menu-button.js +++ b/src/js/menu/menu-button.js @@ -297,7 +297,7 @@ class MenuButton extends Component { handleKeyDown(event) { // Escape or Tab unpress the 'button' - if (event.key === 'Esc' || event.key === 'Tab') { + if (event.key === 'Escape' || event.key === 'Tab') { if (this.buttonPressed_) { this.unpressButton(); } @@ -328,7 +328,7 @@ class MenuButton extends Component { */ handleMenuKeyUp(event) { // Escape hides popup menu - if (event.key === 'Esc' || event.key === 'Tab') { + if (event.key === 'Escape' || event.key === 'Tab') { this.removeClass('vjs-hover'); } } @@ -356,7 +356,7 @@ class MenuButton extends Component { */ handleSubmenuKeyDown(event) { // Escape or Tab unpress the 'button' - if (event.key === 'Esc' || event.key === 'Tab') { + if (event.key === 'Escape' || event.key === 'Tab') { if (this.buttonPressed_) { this.unpressButton(); } diff --git a/test/unit/menu.test.js b/test/unit/menu.test.js index bf47806b2..b07de00d4 100644 --- a/test/unit/menu.test.js +++ b/test/unit/menu.test.js @@ -235,7 +235,7 @@ QUnit.test('should remove old event listeners when the menu item adds to the new assert.ok(clickListenerSpy.calledOnce, 'click event listener should be called'); assert.strictEqual(clickListenerSpy.getCall(0).args[0].target, menuItem.el(), 'event target should be the `menuItem`'); - assert.ok(unpressButtonSpy.calledOnce, '`menuButton`.`unpressButtion` has been called'); + assert.ok(unpressButtonSpy.calledOnce, '`menuButton`.`unpressButton` has been called'); assert.ok(focusSpy.calledOnce, '`menuButton`.`focus` has been called'); unpressButtonSpy.restore(); @@ -265,3 +265,21 @@ QUnit.test('should remove old event listeners when the menu item adds to the new oldMenu.dispose(); menuButton.dispose(); }); + +QUnit.test('Escape should close menu', function(assert) { + const player = TestHelpers.makePlayer(); + const menuButton = new MenuButton(player, {}); + const unpressButtonSpy = sinon.spy(menuButton, 'unpressButton'); + + menuButton.createItems = () => [new MenuItem(player, {})]; + menuButton.update(); + menuButton.handleClick(new window.PointerEvent('click')); + menuButton.menu.children()[0].el_.dispatchEvent(new window.KeyboardEvent('keydown', { + key: 'Escape', + bubbles: true, + cancelable: true + })); + + assert.ok(unpressButtonSpy.calledOnce, '`menuButton`.`unpressButton` has been called'); + +}); From 079cbe1506166026511c01bd48a0bb192699870d Mon Sep 17 00:00:00 2001 From: Bruce Bailey Date: Thu, 14 Nov 2024 03:22:00 -0500 Subject: [PATCH 2/4] fix: change http to https in examples (#8905) Change examples to use https and not http. Co-authored-by: mister-ben <1676039+mister-ben@users.noreply.github.com> --- docs/examples/elephantsdream/index.html | 4 ++-- docs/examples/simple-embed/index.html | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/examples/elephantsdream/index.html b/docs/examples/elephantsdream/index.html index 808171ee5..832885303 100644 --- a/docs/examples/elephantsdream/index.html +++ b/docs/examples/elephantsdream/index.html @@ -5,8 +5,8 @@ Video.js Text Descriptions, Chapters & Captions Example - - + + diff --git a/docs/examples/simple-embed/index.html b/docs/examples/simple-embed/index.html index 5f109248d..e2b44a86b 100644 --- a/docs/examples/simple-embed/index.html +++ b/docs/examples/simple-embed/index.html @@ -10,9 +10,9 @@