Skip to content

Fix #1136 and #1127 #1146

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
merged 1 commit into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/core/event/scroll.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isMobile } from '../util/env';
import * as dom from '../util/dom';
import { removeParams } from '../router/util';
import config from '../config';
import Tweezer from 'tweezer.js';

Expand Down Expand Up @@ -59,8 +60,7 @@ function highlight(path) {
return;
}

const li =
nav[getNavKey(decodeURIComponent(path), last.getAttribute('data-id'))];
const li = nav[getNavKey(path, last.getAttribute('data-id'))];

if (!li || li === active) {
return;
Expand All @@ -86,7 +86,7 @@ function highlight(path) {
}

function getNavKey(path, id) {
return `${path}?id=${id}`;
return `${decodeURIComponent(path)}?id=${decodeURIComponent(id)}`;
}

export function scrollActiveSidebar(router) {
Expand Down Expand Up @@ -127,7 +127,7 @@ export function scrollActiveSidebar(router) {
return;
}

const path = router.getCurrentPath();
const path = removeParams(router.getCurrentPath());
dom.off('scroll', () => highlight(path));
dom.on('scroll', () => highlight(path));
dom.on(sidebar, 'mouseover', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/core/router/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export const isAbsolutePath = cached(path => {
return /(:|(\/{2}))/g.test(path);
});

export const removeParams = cached(path => {
return path.split(/[?#]/)[0];
});

export const getParentPath = cached(path => {
if (/\/$/g.test(path)) {
return path;
Expand Down