Skip to content

Conversation

@Simek
Copy link

@Simek Simek commented Aug 3, 2020

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

This change allows developers to disable the DevMenu (context menu in macOS case) by reusing currently exported isShakeToShowDevMenuEnabled available on iOS addding new setIsSecondaryClickToShowDevMenuEnabled method to the DevSettings:

NativeModules.DevSettings.setIsSecondaryClickToShowDevMenuEnabled(false);

This also improves quite a bit the development process when using Contextual Menus (aka ActionSheetIOS).

Of course I can implement separate, exclusive for macOS, flag if you think it's a better approach.

Also adding [devSettings isDevModeEnabled] like in showOnShake fixed for me DevMenu appearing on the Release build.

Changelog

[macOS] [Added] - add ability to disable DevMenu based on new setIsSecondaryClickToShowDevMenuEnabled method in DevSettings
[macOS] [Fixed] - disable DevMenu when isDevModeEnabled returns false

Test Plan

I have tested the change inside my workbench/sample app, which source code is available here.

Aug-04-2020 01-38-40

Microsoft Reviewers: Open in CodeFlow

@Simek Simek requested a review from tom-un as a code owner August 3, 2020 23:41
@tom-un
Copy link
Collaborator

tom-un commented Aug 10, 2020

Hi @Simek : Just FYI I've been on vacation and will be on vacation for another week. Thanks for the contribution. This is great, but I do think it should have its own DevSetting instead of reusing isShakeToShowDevMenuEnabled. Perhaps isSecondaryClickToShowDevMenuEnabled.

@Simek Simek changed the title allow to disable DevMenu using isShakeToShowDevMenuEnabled allow to disable DevMenu using new method isSecondaryClickToShowDevMenuEnabled Aug 17, 2020
@Simek
Copy link
Author

Simek commented Aug 17, 2020

@tom-un Thank you for the review Tom, I have updated the PR according to the request - there is an macOS exclusive method named isSecondaryClickToShowDevMenuEnabled now and I have tried to add correct macOS merge comments too.

Let me know if it's okay or should I update or change anything else. 🙂

@alloy
Copy link
Member

alloy commented Aug 18, 2020

@tom-un For my understanding, why would it be preferable to add another setting instead of perhaps renaming the existing one, or adding a new generic one and deprecate the existing ‘shake’ one?

@tom-un
Copy link
Collaborator

tom-un commented Aug 19, 2020

@tom-un For my understanding, why would it be preferable to add another setting instead of perhaps renaming the existing one, or adding a new generic one and deprecate the existing ‘shake’ one?

I just feel its cleaner to have prop names that mean what they say. Also there could be shake gesture on mac in the future (there already is via Catalyst) or there could be a secondary click gesture in a future iOS.

desc = NSStringFromClass([_bridge class]);
}
NSString *title = [NSString stringWithFormat:@"React Native: Development\n(%@)", desc];
RCTDevSettings *devSettings = _bridge.devSettings; // TODO(OSS Candidate ISS#2710739)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: this comment is not necessary: this whole block of code is already enclosed in #if TARGET_OS_OSX // [TODO(macOS ISS#2323203) ... #else // ]TODO(macOS ISS#2323203)

Copy link
Author

@Simek Simek Aug 19, 2020

Choose a reason for hiding this comment

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

This comment refers to other issue than macOS fork comment, the line has been copied from showOnShake:

RCTDevSettings *devSettings = _bridge.devSettings; // TODO(OSS Candidate ISS#2710739)

@alloy
Copy link
Member

alloy commented Aug 19, 2020

I just feel its cleaner to have prop names that mean what they say.

Totally agreed, but I also like to have less API surface for ease of discovery. However…

Also there could be shake gesture on mac in the future (there already is via Catalyst) or there could be a secondary click gesture in a future iOS.

…I didn’t consider the real possibility of having multiple ways to to open the menu. Although that thinking also makes me wonder if it shouldn’t be an enum?

Anyways, something to consider longer term, I don’t feel strong about it for this PR.

@Simek
Copy link
Author

Simek commented Aug 20, 2020

Should I update this PR to 0.62 files structure or should I target the 0.61-stable branch instead?

@alloy
Copy link
Member

alloy commented Aug 24, 2020

Update to the 0.62 structure, which is now in master, please 🙏

@Simek
Copy link
Author

Simek commented Aug 24, 2020

Update to the 0.62 structure, which is now in master, please 🙏

Not a problem @alloy, I will work on the changes this week 🙂

@Simek Simek force-pushed the allow-disable-devmenu branch from 5639653 to cc44550 Compare August 31, 2020 15:56
@Simek
Copy link
Author

Simek commented Sep 1, 2020

@alloy Should I force push the branch again to rerun the ci/circleci: test_js? It looks like this failure is not related to the changes in this PR.

@tom-un
Copy link
Collaborator

tom-un commented Sep 1, 2020

@alloy Should I force push the branch again to rerun the ci/circleci: test_js? It looks like this failure is not related to the changes in this PR.

I tried forcing it to re-run and it failed again. I'm not sure why. As a branch of the upstream react-native we get these circleci tests too. They're mostly redundant as we do all the same jest, lint, flow and format-check tests in Azure DevOps. I'll force merge this PR and watch for failures in other PRs.

Thanks!

@tom-un tom-un merged commit a9073e3 into microsoft:master Sep 1, 2020
@HeyImChris
Copy link

@alloy Should I force push the branch again to rerun the ci/circleci: test_js? It looks like this failure is not related to the changes in this PR.

I tried forcing it to re-run and it failed again. I'm not sure why. As a branch of the upstream react-native we get these circleci tests too. They're mostly redundant as we do all the same jest, lint, flow and format-check tests in Azure DevOps. I'll force merge this PR and watch for failures in other PRs.

Thanks!

Late here but they're really flaky. I wouldn't go off of the circle CI tests at all as long as our ADO tests pass.

@alloy
Copy link
Member

alloy commented Sep 1, 2020

@Simek Thanks again for your work! 🙌

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.

4 participants