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

fix: App title drop down close on interaction with other components. #36504

Conversation

saicharan-zemoso
Copy link
Contributor

@saicharan-zemoso saicharan-zemoso commented Sep 24, 2024

Fixes #28114

fixed the app title drop down and it closes on interaction with other components

Before fixing the bug the omni bar and title dropdown overlap over each other:
image

after the fix the app title drop down closes on opening omni bar or any other component.

added the cypress test to visually confirm that the fix was working and did not add unit test as to test this we need to interact with other components or open omni bar while testing.

Summary by CodeRabbit

  • New Features

    • Enhanced the Navigation Menu to automatically close when users interact outside of it, improving user experience.
    • Introduced a test suite for validating application dropdown interactions with the omnibar using keyboard shortcuts.
  • Bug Fixes

    • Resolved an issue where the dropdown menu would remain open after interactions outside its boundaries.

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Walkthrough

This pull request enhances the NavigationMenu component to ensure that the popover menu closes when users interact outside of it. A new function, handleInteractionOutside, is introduced to manage this behavior. Additionally, a new test file has been added to verify the application dropdown's interaction with the omnibar using keyboard shortcuts, ensuring that the dropdown closes appropriately when the omnibar is activated.

Changes

File Change Summary
app/client/cypress/e2e/Regression/ClientSide/... Introduced a test for application dropdown interaction with the omnibar using keyboard shortcuts, validating visibility of menus based on hotkey actions.
app/client/src/pages/Editor/EditorName/Navig... Added onInteractOutside prop to MenuContent, allowing the menu to close when interacting outside of it.

Assessment against linked issues

Objective Addressed Explanation
Ensure dropdown closes when omnibar is opened with hotkeys (#28114)
Menu should close when interacting outside of it

Suggested labels

Bug, UX Improvement, Production, Needs Triaging, IDE Product, IDE Pod, ok-to-test

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007
  • alex-golovanov

Poem

In the dropdown's dance, a new test takes flight,
With hotkeys and menus, all working just right.
A click here, a press there, the popover will close,
As outside interactions bring joy, heaven knows!
So let’s celebrate this code, oh what a delight! 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 29c818a and b01ac45.

📒 Files selected for processing (1)
  • app/client/src/pages/Editor/EditorName/NavigationMenu.tsx (2 hunks)
🧰 Additional context used
🔇 Additional comments (4)
app/client/src/pages/Editor/EditorName/NavigationMenu.tsx (4)

1-1: Well done on importing useCallback!

Class, I'm pleased to see that you've added the import for useCallback from React. This is an excellent practice that will help optimize the performance of our component. Keep up the good work!


16-18: Excellent implementation of handleInteractionOutside!

I'm impressed to see that you've not only added the handleInteractionOutside function but also wrapped it in useCallback. This is a textbook example of optimizing component performance. You've clearly taken the previous feedback to heart and applied it effectively. Well done!

Remember, class, using useCallback here ensures that this function's reference remains stable across re-renders, which can help prevent unnecessary re-renders of child components that depend on this function.


21-21: Great job implementing the onInteractOutside prop!

Students, pay attention to how the handleInteractionOutside function is used here. By adding the onInteractOutside prop to the MenuContent component, we've successfully addressed the issue mentioned in the pull request. This change ensures that the app title dropdown will close when users interact with other components, such as opening the omnibar using hotkeys.

This is an excellent example of how a small, focused change can significantly improve user experience. Well done on implementing this solution!


Line range hint 1-33: Excellent work on improving the NavigationMenu component!

Class, let's review what we've learned from these changes:

  1. The addition of useCallback for the handleInteractionOutside function demonstrates good React practices for performance optimization.
  2. The implementation of the onInteractOutside prop on the MenuContent component effectively addresses the issue of the app title dropdown not closing when interacting with other components.
  3. These changes align perfectly with the pull request objectives and solve the problem described in the linked issue [Bug]: App title drop down pop up is not getting closed automatically when user opens up omnibar using hotkeys #28114.

Overall, this is a well-implemented solution that improves the user experience by ensuring proper behavior of the app title dropdown. Great job on writing clean, efficient code that solves a real user interface problem!

Remember, it's important to test these changes thoroughly, especially with the Cypress test mentioned in the PR summary, to ensure the fix works as expected in various scenarios.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (1)
app/client/cypress/e2e/Regression/ClientSide/OtherUIFeatures/ApplicationDropdownClose_spec.ts (1)

1-2: Class, let's improve our import statements!

Good job on importing the necessary modules, but we can make it even better:

  1. Let's use consistent import syntax. Instead of require, use the import statement for the Omnibar locator.
  2. We should follow camelCase naming convention for imported constants.

Here's how we can refactor these lines:

import homePage from "../../../../locators/HomePage";
import omnibarLocators from "../../../../locators/Omnibar.json";

Remember, consistency is key in coding, just like in your homework assignments!

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9731728 and 29c818a.

Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/OtherUIFeatures/ApplicationDropdownClose_spec.ts (1 hunks)
  • app/client/src/pages/Editor/EditorName/NavigationMenu.tsx (1 hunks)
Additional context used
Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/OtherUIFeatures/ApplicationDropdownClose_spec.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
Additional comments not posted (2)
app/client/src/pages/Editor/EditorName/NavigationMenu.tsx (1)

17-22: Well done, class! This change addresses our dropdown dilemma.

Children, let's examine this wonderful addition to our MenuContent component. The new onInteractOutside prop is like a vigilant hall monitor, ensuring our dropdown behaves properly when we interact with other parts of our application.

This change directly solves the problem described in issue #28114, where our app title dropdown was being a bit stubborn and refusing to close when we opened the omnibar. Now, when you click outside or interact with other components, the dropdown will politely excuse itself and close.

Remember, class, in user interface design, it's important to ensure that our components play nicely with each other. This change is an excellent example of improving user experience through thoughtful interaction handling.

app/client/cypress/e2e/Regression/ClientSide/OtherUIFeatures/ApplicationDropdownClose_spec.ts (1)

4-5: Excellent job on your test descriptions!

Your test suite and case descriptions are clear and informative. They provide a good overview of what's being tested, just like a well-written essay introduction. Keep up the good work!

Copy link

github-actions bot commented Oct 4, 2024

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Oct 4, 2024
@alex-golovanov alex-golovanov self-requested a review October 9, 2024 08:26
@alex-golovanov
Copy link
Contributor

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Oct 9, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11251120175.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36504.
recreate: .

<MenuContent width="214px">
<MenuContent
width="214px"
onInteractOutside={() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will create a new function on every re-render, possibly invalidating cache inside MenuContent. I believe, for that purpose, we have a lint rule for this. As a rule of thumb, if we pass an object to a component, that object should have a stable ref.

Could you please wrap this in a callback?

const handleInteractionOutside = useCallback(() => {
  setIsPopoverOpen(false);
}, [setIsPopoverOpen]);

return (
    <MenuContent
      width="214px"
      onInteractOutside={handleInteractionOutside}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok,sure.

Copy link

github-actions bot commented Oct 9, 2024

Deploy-Preview-URL: https://ce-36504.dp.appsmith.com

@alex-golovanov
Copy link
Contributor

All tests are passing in shadow PR.

@KelvinOm KelvinOm merged commit 4c58a98 into appsmithorg:release Oct 9, 2024
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: App title drop down pop up is not getting closed automatically when user opens up omnibar using hotkeys
4 participants