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

[CP Staging] Fix pressing debug shortcut again won't close the debug modal #51659

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie

const unsubscribeDebugShortcut = KeyboardShortcut.subscribe(
debugShortcutConfig.shortcutKey,
() => Modal.close(toggleTestToolsModal),
() => toggleTestToolsModal(),
debugShortcutConfig.descriptionKey,
debugShortcutConfig.modifiers,
true,
Expand Down
12 changes: 11 additions & 1 deletion src/libs/actions/TestTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import throttle from 'lodash/throttle';
import Onyx from 'react-native-onyx';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import * as Modal from './Modal';

let isTestToolsModalOpen = false;
Onyx.connect({
Expand All @@ -14,7 +15,16 @@ Onyx.connect({
* Throttle the toggle to make the modal stay open if you accidentally tap an extra time, which is easy to do.
*/
function toggleTestToolsModal() {
const toggle = () => Onyx.set(ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN, !isTestToolsModalOpen);
const toggle = () => {
const toggleIsTestToolsModalOpen = () => {
Onyx.set(ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN, !isTestToolsModalOpen);
};
if (!isTestToolsModalOpen) {
Modal.close(toggleIsTestToolsModalOpen);
return;
}
toggleIsTestToolsModalOpen();
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue is that, when pressing the shortcut, we use Modal.close which will close any active modal first. When we press the shortcut for the 2nd time, the debug modal will be closed first and after it's closed we toggle the visibility. But in the test tool modal component, we also toggle the visibility when hidden.

onClose={toggleTestToolsModal}

const throttledToggle = throttle(toggle, CONST.TIMING.TEST_TOOLS_MODAL_THROTTLE_TIME);
throttledToggle();
}
Expand Down
Loading