Skip to content

Improve Side Pane behavior across various Modals and navigation actions #58576

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

Merged

Conversation

blazejkustra
Copy link
Contributor

@blazejkustra blazejkustra commented Mar 17, 2025

Explanation of Change

This PR addresses multiple issues related to the Side Pane visibility and behavior across different elements like the Attachment Modal, Profile Photo Editor and Chat Composer. It ensures that the Help Panel hides when necessary, modals behave consistently, and the chat input regains focus correctly after closing the RHP.

Fixed Issues

$ #57812
$ #57806
$ #58450
$ #57810
PROPOSAL: N/A

Tests

Prerequisite: Open the developer console and run the following snippet:

Onyx.set('nvp_sidePanel', {})
  1. Attachment Modal on any chat (related issue)
  • Open the web/desktop app on a wide screen (Help Panel on the right without an overlay)
  • Add any attachment to chat
  • Verify that Help Panel is hidden for the moment
  1. Edit Profile Photo (related issue)
  • Choose new profile image
  • Verify that you can open (and close) Help Panel
    • ⚠️ Escape and web back button dismisses both edit photo and help panel at once - this is expected and can't be fixed for now
  1. Magic code panel (related issue)
  • Go to Settings > Security.
  • Select a user, access level and proceed to confirmation page.
  • Click Add copilot
  • Verify that magic code modal is displayed as any other RHP
  1. Focusing chat's composer(related issue)
  • Go to any chat and click on the help button at the top
  • Close the help panel
  • Verify that the composer is focused
  1. Hide the Side Pane when opening other RHPs (related issue)
  • Open Help RHP
  • Open other RHP while the Help RHP is open by clicking on CMD J or Shift + CMD + K
  • Verify that the Help Pane is closed and target RHP is opened

Offline tests

N/A

QA Steps

Same as tests

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.webm
Android: mWeb Chrome
and.webm
iOS: Native
ios2.mp4
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-03-18.at.16.00.35.mp4
MacOS: Chrome / Safari
Screen.Recording.2025-03-18.at.13.48.09.mov
Screen.Recording.2025-03-18.at.15.33.29.-.01.mov
Screen.Recording.2025-03-18.at.15.29.20.mov
MacOS: Desktop
Screen.Recording.2025-03-18.at.16.49.20.mov

@@ -39,7 +39,7 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
type === CONST.MODAL.MODAL_TYPE.CENTERED ||
type === CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE ||
type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED ||
CONST.MODAL.MODAL_TYPE.CENTERED_SWIPABLE_TO_RIGHT;
type === CONST.MODAL.MODAL_TYPE.CENTERED_SWIPABLE_TO_RIGHT;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a mistake that was in the code for couple months 😅

import {Animated} from 'react-native';
import {Animated, View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
// @ts-expect-error This is a workaround to display HelpPane on top of everything,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ve really tried every possible approach 😮‍💨

  1. react-native Modal : The modal must be in fullscreen mode; otherwise, the rest of the app becomes unresponsive (users can't click anything outside the side pane)
  2. react-native-modal (src/components/Modal/index.tsx): Similar issue as above, but additionally, the side pane was sometimes rendered under other modals in a non-deterministic way
  3. Portals: The help pane still appeared under React Native modals
  4. react-navigation primitives: Doesn’t work on web
  5. Custom overlay with a very high z-index: React Native modals are still rendered on top, causing the side pane to be hidden

Comment on lines +41 to +44
// Close side pane on small screens when navigation keyboard shortcuts are used
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.SEARCH, onCloseSidePaneOnSmallScreens, {shouldBubble: true});
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.NEW_CHAT, onCloseSidePaneOnSmallScreens, {shouldBubble: true});
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.SHORTCUTS, onCloseSidePaneOnSmallScreens, {shouldBubble: true});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logic for hiding the side pane when user triggers navigation shortcuts:

Screen.Recording.2025-03-18.at.13.48.09.mov

Comment on lines +47 to +60
useEffect(() => {
window.history.pushState({isSidePaneOpen: true}, '', null);
const handlePopState = () => {
if (isExtraLargeScreenWidth) {
return;
}

closeSidePane();
};

window.addEventListener('popstate', handlePopState);
return () => window.removeEventListener('popstate', handlePopState);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part handles the back button behavior on the web. We use a similar approach for Modals/Popovers. It's not perfect, but it works in most cases:

Screen.Recording.2025-03-18.at.14.35.24.mov

One known bug that I won't be able to fix is that when opening both a Modal (src/components/Modal/index.tsx) and the side pane, pressing the back button dismisses both at once instead of handling them separately:

Screen.Recording.2025-03-18.at.14.38.34.mov

const styles = useThemeStyles();
const {isExtraLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const {paddingTop, paddingBottom} = useSafeAreaPaddings();
const [isRHPVisible = false] = useOnyx(ONYXKEYS.MODAL, {selector: (modal) => modal?.type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic is necessary to prevent showing overlay twice:

Screen.Recording.2025-03-18.at.14.29.44.mov

@@ -29,8 +31,9 @@ function useSidePane() {

const [sidePaneNVP] = useOnyx(ONYXKEYS.NVP_SIDE_PANE);
const [language] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE);
const [isAttachmentModalVisible = false] = useOnyx(ONYXKEYS.MODAL, {selector: (modal) => modal?.type === CONST.MODAL.MODAL_TYPE.CENTERED});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is necessary to fix the side pane on large screen:

Screen.Recording.2025-03-18.at.15.29.20.mov

@blazejkustra blazejkustra changed the title Make SidePane compatible with RightDockedModals Improve Side Pane behavior across various Modals and navigation actions Mar 18, 2025
@blazejkustra blazejkustra marked this pull request as ready for review March 18, 2025 16:31
@blazejkustra blazejkustra requested review from a team as code owners March 18, 2025 16:31
@melvin-bot melvin-bot bot requested review from brunovjk and removed request for a team March 18, 2025 16:31
Copy link

melvin-bot bot commented Mar 18, 2025

@brunovjk Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@blazejkustra
Copy link
Contributor Author

@brunovjk I ended up fixing four issues in this PR because they were all closely connected. When I initially tried to address them separately, it actually caused even more problems along the way. Fixing them together allowed me to resolve the underlying bugs more effectively and ensure everything works smoothly.

Let me know if you have any questions!

@brunovjk
Copy link
Contributor

Phew! Lots of work here :D
But I can still reproduce "Magic code panel opens on the wrong panel when help panel is opened #57812":

57812_web_chrome_bug.mov

The rest of the issues seem pretty good to me:

57806 - MacOS: Chrome / Safari
57806_web_chrome.mp4
58450 - MacOS: Chrome / Safari
58450_web_chrome.mov
57810 - MacOS: Chrome / Safari
57810_web_chrome.mp4

I'll keep testing on other platforms, let me know if you have any questions. Thanks a lot!

@brunovjk
Copy link
Contributor

Another detail, please correct me if i'm wrong, we should remove the Help Icon "Modal Avatar" as well, right? I can see the help icon when we open the avatar modal is this PR:
Screenshot 2025-03-19 at 11 05 42

Thanks.

@blazejkustra
Copy link
Contributor Author

But I can still reproduce "Magic code panel opens on the wrong panel when help panel is opened #57812":

@brunovjk Fixed in recent commit, thank you!

@blazejkustra
Copy link
Contributor Author

Another detail, please correct me if i'm wrong, we should remove the Help Icon "Modal Avatar" as well, #58474 (comment)? I can see the help icon when we open the avatar modal is this PR:

It is now removed in the PR you mentioned @brunovjk (here is the exact commit)

@brunovjk
Copy link
Contributor

brunovjk commented Mar 19, 2025

Another detail, please correct me if i'm wrong, we should remove the Help Icon "Modal Avatar" as well, #58474 (comment)? I can see the help icon when we open the avatar modal is this PR:

It is now removed in the PR you mentioned @brunovjk (here is the exact commit)

Great, @blazejkustra should we remove the issue and its testing steps from this same PR description here? And place them in the mentioned PR? The changes seem good to me, but perhaps the QA team could report an errors in items 1 and 2 of the Test Steps of this PR here.

@blazejkustra
Copy link
Contributor Author

blazejkustra commented Mar 19, 2025

Great, @blazejkustra should we remove the issue

Could you link this issue? 🤔

@brunovjk

This comment was marked as off-topic.

@brunovjk
Copy link
Contributor

I think it's getting a little confusing. I'll ask @francoisl to review and merge the other PR first, so we can test it better here. What do you think? Thanks.

@blazejkustra
Copy link
Contributor Author

@brunovjk I merged the newest main for you 👍

@brunovjk
Copy link
Contributor

Great!!! Thank you

@brunovjk
Copy link
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
58576_android_native.mov
Android: mWeb Chrome
58576_android_web.mov
iOS: Native
58576_ios_native.mov
iOS: mWeb Safari
58576_ios_web.mov
MacOS: Chrome / Safari
58576_web_chrome.mp4
MacOS: Desktop
58576_web_desktop.mp4

Copy link
Contributor

@brunovjk brunovjk left a comment

Choose a reason for hiding this comment

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

Now it's much better, I found a bug, but I don't think it's a blocker, we can solve it later, if it's confirmed to be a bug:

  • If the Help panel is open, it stays open after opening the avatar modal:
58576_web_chrome_bug_nab.mov

@melvin-bot melvin-bot bot requested a review from mollfpr March 19, 2025 22:18
Comment on lines +33 to +34
// Close side pane on escape key press
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ESCAPE, () => closeSidePane(), {isActive: !isExtraLargeScreenWidth, shouldBubble: false});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I found an odd behavior while testing this. After closing the pane on a narrow screen (with the escape key or the < arrow) and then expanding to a wide screen view, the modal auto-reopens for some reason. It's also happening on main so NAB.

Screen.Recording.2025-03-19.at.4.58.44.PM.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@francoisl @brunovjk This is the intended way it should work. When transitioning from a wide to a narrow screen, the pane is closed to prevent it from covering the rest of the app. When switching back to a wide screen, the previous state is preserved. If the pane was open before on a large screen, it will be shown again to the user.

That is why there are two booleans in the NVP:

type SidePane = {
    /** Whether the side pane is open on large screens */
    open: boolean;

    /** Whether the side pane is open on small screens */
    openNarrowScreen: boolean;
};

@francoisl
Copy link
Contributor

If the Help panel is open, it stays open after opening the avatar modal:

Same thing happens with the attachment modal on the chat view, but we might end up deciding to add a help description for those routes too, so I think it's fine to keep as is.

@francoisl francoisl merged commit affc50f into Expensify:main Mar 20, 2025
17 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@blazejkustra
Copy link
Contributor Author

If the Help panel is open, it stays open after opening the avatar modal:

Same thing happens with the attachment modal on the chat view, but we might end up deciding to add a help description for those routes too, so I think it's fine to keep as is.

My intention was to hide the help pane when attachment modal is displayed, and reopen it after:

Screen.Recording.2025-03-20.at.09.07.23.mov

I missed the case with avatar modal, will fix it in Stage 3:

Screen.Recording.2025-03-20.at.09.41.41.mov

Copy link
Contributor

🚀 Deployed to staging by https://github.com/francoisl in version: 9.1.16-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅
🤖🔄 android HybridApp 🤖🔄 success ✅
🍎🔄 iOS HybridApp 🍎🔄 success ✅

@pecanoro
Copy link
Contributor

It seems this PR could have caused this deploy blocker: #58818

@izarutskaya
Copy link

@blazejkustra PR is failing with issues #58818, #58823, #58831

@blazejkustra
Copy link
Contributor Author

@blazejkustra PR is failing with issues #58818, #58823, #58831

Thanks! One was just closed, while the other two issues will be fixed in Stage 3 PR. None are deploy blockers as Side Pane is not displayed on prod.

Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 9.1.16-4 🚀

platform result
🤖 android 🤖 true ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅
🤖🔄 android HybridApp 🤖🔄 failure ❌
🍎🔄 iOS HybridApp 🍎🔄 failure ❌

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.

7 participants