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

DOP-4883: Menu not closing after selection on Mobile #1254

Merged
merged 16 commits into from
Oct 1, 2024
Merged

Conversation

biancalaube
Copy link
Collaborator

@biancalaube biancalaube commented Sep 24, 2024

Stories/Links:

DOP-4883

Current Behavior:

Current Behavior

  • If you are on mobile you have to select the top docs menu button to get rid of the menu/sidenav once you select a site

Staging Links:

Stagging Behavior

  • Now when you select on a link (that is not a twisty) it should automatically get rid of the menu/sidenav (on mobile)

Notes:

README updates

    • This PR introduces changes that should be reflected in the README, and I have made those updates.
    • This PR does not introduce changes that should be reflected in the README

Copy link

netlify bot commented Sep 24, 2024

Deploy Preview for mongodb-snooty ready!

Name Link
🔨 Latest commit d76df15
🔍 Latest deploy log https://app.netlify.com/sites/mongodb-snooty/deploys/66fc5a642a97c000082b09dd
😎 Deploy Preview https://deploy-preview-1254--mongodb-snooty.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@mayaraman19 mayaraman19 left a comment

Choose a reason for hiding this comment

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

Nice work, thanks for picking this up! I think there are a couple things that need a bit of tweaking:

  • I actually think the previous behavior you showed in Slack was what we were looking for, where clicking on the text of the link opens the page and hides the Sidenav (even if there are children)
  • I think because we are not using the setIsOpen(!isOpen) anymore, if you click on an opened caret (on Desktop) it doesn't close anymore (for example, navigate to a page with children and then click on the sidenav item (text or twisty) for the current page you're on - in prod it closes back up). You will also see one of the tests failing because of this! If we can preserve the current behavior of the dropdown so that you can open and close the side nav item even when you're on the page that would be great!

@biancalaube
Copy link
Collaborator Author

@mayaraman19

Thanks for the comments! Both things should be fixed by the 2 latest commits. Please review again and let me know if you see more issues :)

Copy link
Collaborator

@mayaraman19 mayaraman19 left a comment

Choose a reason for hiding this comment

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

Hey Bianca, thanks for addressing the feedback! I did leave one more comment below!

@@ -82,6 +82,11 @@ const TOCNode = ({ activeSection, handleClick, level = BASE_NODE_LEVEL, node, pa
setIsOpen(!isOpen);
};

const clickSideNav = (handleClick) => {
setIsOpen(!isOpen);
Copy link
Collaborator

@mayaraman19 mayaraman19 Sep 27, 2024

Choose a reason for hiding this comment

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

oh no, now the carets/"twisties" are being treated like text in mobile sidenav in that if you click them they open the page and hide the sidenav, instead of just opening the caret to see the children dropdown. I think setting the state here is probably interfering with onCaretClick. Lmk if you want to discuss this more!

Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed! i think we can leave the behaviors as is, and actually add a listener on location change that closes the mobile menu. ie something like this pattern

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@seungpark , Im a little confused on how the link you sent is suppose to fix my issue. Sould I not be using the handleclick() anymore that I passed in from sidenav.js ? And rewrite that function in the tocnode.js file.

Copy link
Collaborator

@seungpark seungpark Sep 27, 2024

Choose a reason for hiding this comment

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

i think this is more of a set state to close menu on location change than on sidenav button click (which would trigger a location change). lmk if that makes sense!

we can leave the behaviors as is

I meant as to leave the current click handlers, and add a new effect in the component to listen for location changes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@seungpark and @mayaraman19 . Thanks for the advice I made a change that I think changes this problem. Please let me know if you see anything else.

Copy link
Collaborator

@seungpark seungpark left a comment

Choose a reason for hiding this comment

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

left a suggestion for closing the menu on location change!

@@ -82,6 +82,11 @@ const TOCNode = ({ activeSection, handleClick, level = BASE_NODE_LEVEL, node, pa
setIsOpen(!isOpen);
};

const clickSideNav = (handleClick) => {
setIsOpen(!isOpen);
Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed! i think we can leave the behaviors as is, and actually add a listener on location change that closes the mobile menu. ie something like this pattern

Copy link
Collaborator

@seungpark seungpark left a comment

Choose a reason for hiding this comment

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

this LGTM! minor comments below. please resolve package (no diffs!) before merge!

Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure why we have changes here! there shouldnt be any diff if we merge master into your branch

@@ -203,6 +205,11 @@ const Sidenav = ({ chapters, guides, page, pageTitle, repoBranches, slug, eol })
setHideMobile(true);
}, [setHideMobile]);

// close navigation panel on mobile screen, but leaves open if they click on a twsity
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor typo in comment!

Copy link
Collaborator

@mayaraman19 mayaraman19 left a comment

Choose a reason for hiding this comment

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

nice! glad you got the path prefix thing figured out as well. looks good after seung's comments have been addressed

@seungpark
Copy link
Collaborator

discussed offline of the package diff. this was failing in main branch so this actually will resolve this !

@biancalaube biancalaube merged commit 4e972ca into main Oct 1, 2024
8 checks passed
@biancalaube biancalaube deleted the DOP-4883 branch October 1, 2024 20:45
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.

3 participants