Skip to content

Website: Fix in page nav / left nav display bug#4199

Merged
Jahnp merged 12 commits intomicrosoft:masterfrom
lynamemi:in-page-nav-bug
Mar 8, 2018
Merged

Website: Fix in page nav / left nav display bug#4199
Jahnp merged 12 commits intomicrosoft:masterfrom
lynamemi:in-page-nav-bug

Conversation

@lynamemi
Copy link
Copy Markdown
Collaborator

@lynamemi lynamemi commented Mar 6, 2018

Pull request checklist

  • Addresses an existing issue: Fixes #0000
  • Include a change request file using $ npm run change

Description of changes

Left nav would disappear when you clicked on an in-page navigation link (like 'Best Practices' or 'Implementation').

By default, links in the nav are set to display: none. The logic to check whether the link isActive or hasActiveChild (and set display to visible) was failing. Not sure why, because no recent changes have been made.

I changed up how paths are generated for in-page nav to be more informative. They now will look like this:
#/components/activityitem#BestPractices
instead of:
#BestPractices

Then I reworked the logic for displaying the appropriate links.

Focus areas to test

(optional)

@lynamemi lynamemi requested review from Jahnp and mikewheaton March 6, 2018 23:13

return _urlResolver.href === target;
path = getPathMinusLastHash(path);
if (path === target) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe I'm misunderstanding the code here--but why are we evaluating if (path === target) twice: once after getting the href (new line 101), then again after stripping out the hash (line 106)? Can these be simplified?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Very fair point. It's in there twice because of the double hash situation - we only need the second if (path === target) for those cases. I refactored to do a hash count with one if (path === target) to make it more clear what the code is aiming for.

@lynamemi
Copy link
Copy Markdown
Collaborator Author

lynamemi commented Mar 8, 2018

@Jahnp are you good with the refactor?

@Jahnp
Copy link
Copy Markdown
Member

Jahnp commented Mar 8, 2018

@lynamemi thanks--this is much cleaner. Looks great to me!

@Jahnp Jahnp merged commit e67bcbe into microsoft:master Mar 8, 2018
@lynamemi lynamemi deleted the in-page-nav-bug branch March 8, 2018 17:46
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants