-
Notifications
You must be signed in to change notification settings - Fork 3
Bugfix/iterate over selectable elements #294
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
Bugfix/iterate over selectable elements #294
Conversation
✅ Deploy Preview for firefox-devtools-react-contextmenu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
| } | ||
|
|
||
| if ([MenuItem, this.getSubMenuType()].indexOf(child.type) < 0) { | ||
| if ([MenuItem, this.getSubMenuType()].indexOf(child.type) < 0 && child.props.children instanceof Object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for a menu that looks like the test below:
<ContextMenu id={data.id} onHide={jest.fn()}>
<MenuItem onClick={jest.fn()}>Item 1</MenuItem>
<MenuItem onClick={jest.fn()}>Item 2</MenuItem>
<div>custom-content</div>
</ContextMenu>what happens then? Is the div part of the collected children? I feel like it shouldn't, but maybe I'm wrong (as it could be good for accessibility).
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the div becomes a part of the collected children.
If the library allows adding custom elements and displays them in the menu, then I believe it should allow selecting them with the keyboard as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see; I was thinking that it would be more like headers to separate groups, and then we wouldn't want to select them...
but I don't know really.
I think @canova experimented a bit with adding custom content in the profiler UI's track button. @canova would you have an opinion about this? On my side I don't mind landing this if you agree too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if I remember correctly I wasn't very happy with the way we collect children in the menu. But I think it's fine to collect custom content there. And this PR is mostly making sure that we don't throw an error, so I think this PR is fine.
canova
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
| } | ||
|
|
||
| if ([MenuItem, this.getSubMenuType()].indexOf(child.type) < 0) { | ||
| if ([MenuItem, this.getSubMenuType()].indexOf(child.type) < 0 && child.props.children instanceof Object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if I remember correctly I wasn't very happy with the way we collect children in the menu. But I think it's fine to collect custom content there. And this PR is mostly making sure that we don't throw an error, so I think this PR is fine.

The library allows to use custom html elements next to menu items, but throws an error when using the keyboard to navigate.
To reproduce the issue, remove the fix and run the unit test
should allow keyboard actions when menu contains a non menu item element.The fix does not introduce any new functionality, but rather makes the current implementation more explicit and fail-proof.