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

[v2] Add smart default context-menu functionality (backported from v3) #2748

Merged
merged 2 commits into from Jun 27, 2023

Conversation

mmghv
Copy link
Contributor

@mmghv mmghv commented Jun 27, 2023

Description

This PR backports the "smart" default context-menu functionality from v3.

This feature allows the default context-menu to only be available in text contexts by default, which can be controlled with the --default-contextmenu CSS style, this feature only works in production, in dev & debug the full default context-menu is always enabled.

Reference #2733

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Windows
  • macOS
  • Linux

How to test :

Enable the EnableDefaultContextMenu app option, then using this index.zip html file, you can test all scenarios, in production it should work, in dev & debug it should have no effect and the default context-menu should always be available.

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@mmghv mmghv marked this pull request as ready for review June 27, 2023 12:41
This rule is inherited like any normal CSS rule, so nesting works as expected.

:::note
This filtering functionality is only enabled in production, so in development and in debug build, the full context-menu is always available everywhere.
Copy link
Member

Choose a reason for hiding this comment

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

I think that if you right click a background with no text in debug mode, it won't be available as the current check is CSS only - it has no idea it's in dev mode. We could implement that by setting flags.debug to true and checking it as part of processDefaultContextMenu

Copy link
Contributor Author

@mmghv mmghv Jun 27, 2023

Choose a reason for hiding this comment

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

It skips it all together in the runtime in dev & debug :

https://github.com/wailsapp/wails/pull/2748/files#diff-110ff4bc4cc00d585c83f35398997ba75ba4dca549a87847cf50cb37a62ac240R190-R199

So right clicking anywhere shows the context menu in dev & debug, that's why I needed the previous PR 😉

You can test locally to confirm 👍

Copy link
Member

Choose a reason for hiding this comment

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

Ooooh! I totally missed that nuance! Awesome.

Copy link
Member

@leaanthony leaanthony 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 doing this 🙏

@leaanthony leaanthony merged commit 8acbdc2 into wailsapp:master Jun 27, 2023
16 checks passed
@mmghv mmghv deleted the feature/smart-default-conext-menu branch June 28, 2023 02:17
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.

None yet

2 participants