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 mobile doc sidebar #1279

Merged
merged 3 commits into from
May 13, 2020
Merged

Conversation

iKBAHT
Copy link
Contributor

@iKBAHT iKBAHT commented May 11, 2020

Fixes #808

There is some conflict in the mobile doc sidebar. Some root sidebar items have their own articles. When the user clicks to that item two things happen:

  1. article opens
  2. submenu in the sidebar collapsed

On mobile this cause problem because both logic can't be visible at the same time. I think a better way to solve the issue is to separate 1 and 2 logic to different clicks (ie need special UI element to collapse submenu). To do it need some other design for a mobile sidebar.

As a quick fix, I implement the following logic: the mobile doc sidebar doesn't close on navigating until leaf item is selected.

@iKBAHT
Copy link
Contributor Author

iKBAHT commented May 11, 2020

yarn format-check failed, but it also failed on master 59a570c

@shcheklein shcheklein temporarily deployed to dvc-landing-fix-mobile--w2h63z May 11, 2020 22:39 Inactive
@@ -60,10 +60,6 @@

&:hover {
color: #3c3937;

@media (--xs-scr) {
Copy link
Member

Choose a reason for hiding this comment

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

@iKBAHT why do we remove this?

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 fixed bug.

Steps:

  • Open docs in mobile
  • Open sidebar
  • Click to "Install"

Exp: "Install" is highlighted
Act: "Install" remains as it was

Copy link
Member

Choose a reason for hiding this comment

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

Not an easy to test in the preview environment for me (your change - this one removal) to see the bug you mention. But this one removal introduces another one for me - when I move the sidebar with my finger it highlights (and keep it highlighted) any item under my finger. So, you kinda see two items highlighted at once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, it is my fail. I fix this and fix the bug that I found.

@@ -40,6 +40,8 @@ const SidebarMenuItem: React.FC<ISidebarMenuItemProps> = ({
const isActive = activePaths && includes(activePaths, path)
const isRootParent =
activePaths && activePaths.length > 1 && activePaths[0] === path
const isLeafItem = children === undefined || children.length === 0
Copy link
Member

Choose a reason for hiding this comment

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

(not sure we need to change or fix this in this PR) curious - is it undefined or zero length array after all? this check feels a bit excessive.

Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't currently necessary as no sidebar items return empty arrays (and probably won't as long as it's defined as JSON). On top of that, if the issue ever arises we can control for that kind of thing at build time.
Removing this extra check is a micro-optimization, but a valid one nonetheless.

Copy link
Member

@shcheklein shcheklein left a comment

Choose a reason for hiding this comment

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

looks good to me! just a couple comments to address/discuss.

@shcheklein shcheklein requested a review from rogermparent May 11, 2020 23:57
@rogermparent
Copy link
Contributor

rogermparent commented May 12, 2020

I'll run this as well, but simply looking at the code doesn't make any issues jump out to me. I'll also try to address @shcheklein's comments.

Copy link
Contributor

@rogermparent rogermparent left a comment

Choose a reason for hiding this comment

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

The code looks fine to me. The zero-length array check @shcheklein pointed out is benign but unnecessary right now, so I'll leave it to him to decide if we want to approve this now or after that is addressed. I'd also like to know why that bit of CSS was removed.

Besides that, I approve. Thanks for the fix!

@shcheklein shcheklein temporarily deployed to dvc-landing-fix-mobile--w2h63z May 12, 2020 16:32 Inactive
@shcheklein shcheklein temporarily deployed to dvc-landing-fix-mobile--w2h63z May 13, 2020 13:12 Inactive
@iKBAHT iKBAHT force-pushed the fix-mobile-sidebar branch from 47719aa to 98ec846 Compare May 13, 2020 13:14
@shcheklein shcheklein temporarily deployed to dvc-landing-fix-mobile--w2h63z May 13, 2020 13:15 Inactive
@iKBAHT
Copy link
Contributor Author

iKBAHT commented May 13, 2020

Rebased from the master

@shcheklein shcheklein merged commit 0ccde89 into iterative:master May 13, 2020
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.

doc sidebar menu on mobile, don't close it on navigate
3 participants