Skip to content

Commit

Permalink
Ignore titles in menu, if they exist.
Browse files Browse the repository at this point in the history
This is because of the change in videojs#3163 where we added the title as an
item in the childrens array so that it is ordered correctly but this
breaks keyboard support because they expect the children to be lined up
correctly and also because they expect the children to be component
objects with an 'el_' property.
Checking to see if the first item is a 'vjs-menu-title' and adding one
to the 'item' allows us to ignore the title element and also select the
actual menu items.
  • Loading branch information
gkatsev committed Mar 9, 2016
1 parent 3367b00 commit 6cb7b9f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/js/menu/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ class Menu extends Component {
item = children.length - 1;
}

let haveTitle = children[0].className &&
/vjs-menu-title/.test(children[0].className);

if (item === 0 && haveTitle) {
item = 1;
}

this.focusedChild_ = item;

children[item].el_.focus();
Expand Down

1 comment on commit 6cb7b9f

@OwenEdwards
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically there could be a title and no other children, in which case children[item].el_.focus() would still throw an error.

And if we're going to check if children[item].el_ exists, then we could use that as the test for a title too, right?

Please sign in to comment.