Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(menu-surface): add component #295

Merged
merged 28 commits into from
Oct 3, 2018
Merged

feat(menu-surface): add component #295

merged 28 commits into from
Oct 3, 2018

Conversation

moog16
Copy link

@moog16 moog16 commented Sep 27, 2018

fixes #188

@moog16 moog16 added this to the 0.6.0 milestone Sep 27, 2018
@@ -0,0 +1,149 @@
# React Menu Surface

This comment was marked as resolved.

@codecov-io
Copy link

codecov-io commented Sep 28, 2018

Codecov Report

Merging #295 into master will increase coverage by 0.09%.
The diff coverage is 98.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #295      +/-   ##
==========================================
+ Coverage   97.14%   97.24%   +0.09%     
==========================================
  Files          35       36       +1     
  Lines        1367     1489     +122     
  Branches      131      163      +32     
==========================================
+ Hits         1328     1448     +120     
- Misses         39       41       +2
Impacted Files Coverage Δ
packages/menu-surface/index.js 98.36% <98.36%> (ø)

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 97ecb3a...22edf57. Read the comment docs.

@moog16 moog16 changed the title feat(menu surface): add component feat(menu-surface): add component Sep 28, 2018
Copy link
Contributor

@bonniezhou bonniezhou left a comment

Choose a reason for hiding this comment

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

It seems like setting the anchor corner doesn't do the same thing as in MDC Web...try setting it to BOTTOM_END and see what happens

window.removeEventListener('contextmenu', this.rightClickCallback_);
}

setAnchorElement = (element) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why update state here instead of using createRef?

Copy link
Author

Choose a reason for hiding this comment

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

I want the component to re-render when the ref is set. I put it on state, so that it renders again once it sets. Otherwise I did a forceRender(), which isn't as obvious.

}

hoistToBody() {
// this deviatees from the mdc web version.
Copy link
Contributor

Choose a reason for hiding this comment

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

"deviates"

// this deviatees from the mdc web version.
// here we force the menu to hoist, and require either
// this.props.(x,y) or this.props.anchorElement.
if (!(this.menuSurfaceElement_ && this.menuSurfaceElement_.current)) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can remove the null check for this.menuSurfaceElement_

Copy link
Author

Choose a reason for hiding this comment

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

I think its safer to keep it in. adapter.restoreFocus is called within foundation.close(). foundation.close is called in handleBodyClick and handleKeydown, which are async events. There is the possibility that the MenuSurface is unmounted before a keydown event or a click event occurs, which would cause an error.

What do you think?

@moog16
Copy link
Author

moog16 commented Oct 1, 2018

I think its the same I attached screenshots of web and react both set to BOTTOM_END

screen shot 2018-10-01 at 16 45 51

screen shot 2018-10-01 at 16 45 55

Copy link
Contributor

@bonniezhou bonniezhou left a comment

Choose a reason for hiding this comment

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

One typo, otherwise LGTM!

removeMenuFromBody(wrapper);
});

test('update to props.open sets firstFocusableElement_', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

"lastFocusableElement_"

@bonniezhou
Copy link
Contributor

Oh one thing I noticed was that the menu surface doesn't trap focus like the MDC Web one. We can either fix that in this PR or open a new bug for it

@moog16 moog16 merged commit 034abd0 into master Oct 3, 2018
@moog16 moog16 deleted the feat/menu-surface branch October 3, 2018 22:01
@moog16
Copy link
Author

moog16 commented Oct 4, 2018

@bonniezhou I don't think menu-surface traps focus. Menu does - is that what you meant?

@bonniezhou
Copy link
Contributor

Oh it might have been menu that I was looking at. Disregard! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants