diff --git a/src/js/menu/menu-button.js b/src/js/menu/menu-button.js index 7b8ad9aa3..274b48626 100644 --- a/src/js/menu/menu-button.js +++ b/src/js/menu/menu-button.js @@ -58,11 +58,7 @@ class MenuButton extends Component { this.on(this.menuButton_, 'tap', handleClick); this.on(this.menuButton_, 'click', handleClick); this.on(this.menuButton_, 'keydown', (e) => this.handleKeyDown(e)); - this.on(this.menuButton_, 'mouseenter', () => { - this.addClass('vjs-hover'); - this.menu.show(); - Events.on(document, 'keyup', this.handleMenuKeyUp_); - }); + this.on('mouseenter', (e) => this.handleMouseEnter(e)); this.on('mouseleave', (e) => this.handleMouseLeave(e)); this.on('keydown', (e) => this.handleSubmenuKeyDown(e)); } @@ -263,6 +259,20 @@ class MenuButton extends Component { Events.off(document, 'keyup', this.handleMenuKeyUp_); } + /** + * + * @param {Event} event + * The `mouseenter` event that caused this function to be called. + * + * @listens mouseenter + */ + handleMouseEnter(event) { + this.addClass('vjs-hover'); + this.buttonPressed_ = true; + this.menu.show(); + Events.on(document, 'keyup', this.handleMenuKeyUp_); + } + /** * Set the focus to the actual button, not to this element */ diff --git a/test/unit/menu/menu-button.test.js b/test/unit/menu/menu-button.test.js new file mode 100644 index 000000000..3b40fd9c2 --- /dev/null +++ b/test/unit/menu/menu-button.test.js @@ -0,0 +1,13 @@ +/* eslint-env qunit */ +import TestHelpers from '../test-helpers.js'; + +QUnit.module('MenuButton', { + beforeEach(assert) { + this.player = TestHelpers.makePlayer({ + + }); + }, + afterEach(assert) { + this.player.dispose(); + } +});