Skip to content

[Menu] Fix focus issue#8769

Merged
oliviertassinari merged 1 commit into
mui:masterfrom
zentron:patch-2
Oct 20, 2017
Merged

[Menu] Fix focus issue#8769
oliviertassinari merged 1 commit into
mui:masterfrom
zentron:patch-2

Conversation

@zentron

@zentron zentron commented Oct 20, 2017

Copy link
Copy Markdown

Fix condition where item is removed from menu before it is attempted to be used in focus calculation.

Clicking a menu item triggers an event which can end up causing that item to be removed from the menu. If that is the last item in that menu then the menu disappears, but this focus event triggers and an exception is thrown since focusedItem is null

Fix condition where item is removed from menu before it is attempted to be used in focus calculation.

@oliviertassinari oliviertassinari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be perfect with a test case, but that's not that important given the master branch is in the end of his cycle life. Thanks for taking the time to open a PR!

Comment thread src/Menu/Menu.js
const filteredChildren = this.getFilteredChildren(this.props.children);
const focusedItem = filteredChildren[focusIndex];
if (focusedItem.props.menuItems && focusedItem.props.menuItems.length > 0) {
if (!!focusedItem && focusedItem.props.menuItems && focusedItem.props.menuItems.length > 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the following check enough? if (focusedItem &&

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

suppose i don't see why not. I sometimes go overboard with ensuring i've got a bool :)

@jony89 jony89 Nov 27, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

btw, the minified file translate it to
o&&o.props.menuItems&&o.props.menuItems.length>0
so !! really does not matter :)

@oliviertassinari oliviertassinari added type: bug It doesn't behave as expected. scope: menu Changes related to the menu. v0.x labels Oct 20, 2017
@oliviertassinari oliviertassinari changed the title Update Menu.js [Menu] Fix focus issue Oct 20, 2017
@oliviertassinari
oliviertassinari merged commit 77fbba7 into mui:master Oct 20, 2017
@oliviertassinari

Copy link
Copy Markdown
Member

@zentron Thanks

@zentron

zentron commented Oct 20, 2017

Copy link
Copy Markdown
Author

Thanks @oliviertassinari for the quick merge!

@zentron
zentron deleted the patch-2 branch October 20, 2017 11:50
djbuckley added a commit to manchesergit/material-ui that referenced this pull request Oct 27, 2017
* call_em_all_-_master/master:
  mui#8863 [AutoComplete] fix undef dataSource.value (mui#8864)
  [docs] Add FlyWeekend in showcase (mui#8812)
  Update Menu.js (mui#8769)
  [docs] added a web app to showcase (mui#8767)
@jony89

jony89 commented Nov 27, 2017

Copy link
Copy Markdown
Contributor

not sure why this has not been published yet ? @oliviertassinari

if we follow SEMVER , there should have been one published version after this commit. it has been more than a month :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: menu Changes related to the menu. type: bug It doesn't behave as expected. v0.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants