Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

fix(menu): Close menu even when a list-item was clicked. #1756

Merged
merged 3 commits into from
Feb 2, 2018
Merged

fix(menu): Close menu even when a list-item was clicked. #1756

merged 3 commits into from
Feb 2, 2018

Conversation

simono
Copy link
Contributor

@simono simono commented Dec 13, 2017

Previously clicks on a list-item in the page would leave the menu open. Now we check if a item in this menu was clicked and leave the menu open.

Fixes #1747

@amsheehan You introduced this behavior in 02fe795. Is my fix correct?

@codecov-io
Copy link

codecov-io commented Dec 13, 2017

Codecov Report

Merging #1756 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1756      +/-   ##
==========================================
- Coverage   99.14%   99.14%   -0.01%     
==========================================
  Files          90       90              
  Lines        3845     3843       -2     
  Branches      497      497              
==========================================
- Hits         3812     3810       -2     
  Misses         33       33
Impacted Files Coverage Δ
packages/mdc-menu/constants.js 100% <ø> (ø) ⬆️
packages/mdc-menu/index.js 93.9% <ø> (-0.08%) ⬇️
packages/mdc-menu/foundation.js 99.35% <100%> (-0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d83d5bd...3942fa0. Read the comment docs.

Copy link
Contributor

@patrickrodee patrickrodee left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Got a few small things that are more style and formatting but looks pretty good from here.

@@ -282,7 +281,7 @@ class MDCSimpleMenuFoundation extends MDCFoundation {
let el = evt.target;

while (el && el !== document.documentElement) {
if (this.adapter_.eventTargetHasClass(el, cssClasses.LIST_ITEM)) {
if (this.adapter_.getIndexForEventTarget(el) >= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nitpick: I'd suggest updating the JSDoc description to explain that it cancels if it's not a child item instead of just a list item.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, perhaps just personal preference, but I prefer checks to be as explicit as possible so it might be a good idea to change the comparator from >= 0 to !== -1

@simono
Copy link
Contributor Author

simono commented Dec 22, 2017

@patrickrodee Thanks for the Review. I updated the PR.

@simono
Copy link
Contributor Author

simono commented Jan 10, 2018

@patrickrodee I rebased my branch on master. Anything else I can do to get this merged? Thanks!

@williamernest williamernest requested review from williamernest and removed request for williamernest January 25, 2018 16:36
@williamernest williamernest self-assigned this Jan 25, 2018
Previously clicks on a list-item in the page would leave the menu open.
Now we check if a item in this menu was clicked and leave the menu open.

Fixes #1747
@simono
Copy link
Contributor Author

simono commented Feb 2, 2018

@williamernest I rebased my branch once again and it should apply cleanly now. Let me know if there's anything I can help out with. Thanks!

Copy link
Contributor

@williamernest williamernest left a comment

Choose a reason for hiding this comment

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

LGTM

@williamernest williamernest merged commit c052cfe into material-components:master Feb 2, 2018
@simono simono deleted the fix-select-menu-close branch February 3, 2018 09:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Select menu does not close when clicking
4 participants