From f352aa129a0264671d7e294a1f895eb1beddc3f1 Mon Sep 17 00:00:00 2001 From: Jhen Date: Mon, 20 Mar 2017 12:40:16 -0700 Subject: [PATCH] Add missing `toggleElementInspector` event send when `jsLoaded` Summary: - [x] Explain the **motivation** for making this change. - [x] Provide a **test plan** demonstrating that the code is solid. - [x] Match the **code formatting** of the rest of the codebase. - [x] Target the `master` branch, NOT a "stable" branch. The PR #11613 (0.43) removed this missing `toggleElementInspector` event send when `jsLoaded` in DevMenu (Now is DevSettings), it should open the inspector if `isElementInspectorShown` is true when we reload JS. The dev menu text `Show / Hide Inspector` is dependent on `isElementInspectorShown` bool value. ([This behavior in 0.42](https://github.com/facebook/react-native/blob/0.42-stable/React/Modules/RCTDevMenu.mm#L436-L442)) Manual testing in UIExplorer: * Open the dev menu and click `Show Inspector` * Open the dev menu and click `Reload JS` * The built-in inspector should keep open (dev menu text: `Hide Inspector`) Closes https://github.com/facebook/react-native/pull/12999 Differential Revision: D4738959 Pulled By: javache fbshipit-source-id: b3f584db51aa0e1b463c52003967b00bcd81bc99 --- React/Modules/RCTDevSettings.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/React/Modules/RCTDevSettings.mm b/React/Modules/RCTDevSettings.mm index 171b25320..d97aa6031 100644 --- a/React/Modules/RCTDevSettings.mm +++ b/React/Modules/RCTDevSettings.mm @@ -454,6 +454,14 @@ RCT_EXPORT_METHOD(toggleElementInspector) dispatch_async(dispatch_get_main_queue(), ^{ // update state again after the bridge has finished loading [self _synchronizeAllSettings]; + + // Inspector can only be shown after JS has loaded + if ([self isElementInspectorShown]) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [self.bridge.eventDispatcher sendDeviceEventWithName:@"toggleElementInspector" body:nil]; +#pragma clang diagnostic pop + } }); }