Skip to content

Conversation

@juskevicius
Copy link

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.

@netlify
Copy link

netlify bot commented Mar 3, 2025

Deploy Preview for firefox-devtools-react-contextmenu ready!

Name Link
🔨 Latest commit 3f0c6d2
🔍 Latest deploy log https://app.netlify.com/sites/firefox-devtools-react-contextmenu/deploys/67ca06b257e42c0009cf0052
😎 Deploy Preview https://deploy-preview-294--firefox-devtools-react-contextmenu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 91
Accessibility: 82
Best Practices: 92
SEO: 92
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@julienw julienw self-requested a review March 5, 2025 07:43
}

if ([MenuItem, this.getSubMenuType()].indexOf(child.type) < 0) {
if ([MenuItem, this.getSubMenuType()].indexOf(child.type) < 0 && child.props.children instanceof Object) {
Copy link

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?

Copy link
Author

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.

Copy link

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!

Copy link
Member

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.

@julienw julienw requested a review from canova March 7, 2025 10:17
Copy link
Member

@canova canova left a 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) {
Copy link
Member

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 canova merged commit a9c5c35 into firefox-devtools:master Mar 13, 2025
6 checks passed
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