This makes right/left arrows on the menubar and up/down arrows on theDoes this seem like the right behavior?
// Directional focus in menu item lists always loops, whether in a menubarThis seems like one of those cases where there's probably a clever way to make this code 5-10 lines shorter, but I don't currently see it...
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
This makes right/left arrows on the menubar and up/down arrows on theDoes this seem like the right behavior?
Quick note that this was removed from the commit description - likely good to put it back.
Now to your question. I do think looping sounds like the right behavior, I think that's what Erin's UX doc concluded (correct me if I'm wrong). For a11y, it does mean we need to expose posinset and setsize, so that a user knows "when" they've looped back around.
if (forward) {
menu_item_list_iterator = begin();
} else {
menu_item_list_iterator = last();
}This could be ternary, saving 4 lines.
HTMLMenuItemElement* this_item = &*menu_item_list_iterator;This seems like perhaps you should add a (non-explicit) `operator HTMLMenuItemElement*()` for `MenuItemListIterator`?
if (first_item_tested) {
if (this_item == first_item_tested) {
// We've tested all the items and none is focusable.
return nullptr;
}
} else {
first_item_tested = this_item;
}
if (this_item->IsFocusable()) {
return this_item;
}Not much different, so take it or leave it, but:
```
if (item == first_item_tested) {
return nullptr;
}
if (!first_item_tested) {
first_item_tested = item;
}
if (item->IsFocusable()) {
return item;
}
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |