Skip to content

Commit

Permalink
fix: decode the value of location.hash as event callback params
Browse files Browse the repository at this point in the history
  • Loading branch information
子奂 committed Jan 4, 2020
1 parent 9f38d1b commit 9a284a0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ export class MarkdownNavbar extends Component {
return headingList;
}

_getCurrentHashValue = () => window.location.hash.replace(/^#/, '');
_getCurrentHashValue = () =>
decodeURIComponent(window.location.hash.replace(/^#/, ''));

_winScroll = () => {
const scrollTop =
Expand All @@ -209,7 +210,9 @@ export class MarkdownNavbar extends Component {

if (this.props.updateHashAuto) {
// Hash changing callback
this.props.onHashChange(curHeading.dataId, this._getCurrentHashValue());
if (curHeading.dataId !== this._getCurrentHashValue()) {
this.props.onHashChange(curHeading.dataId, this._getCurrentHashValue());
}

this._updateHash(curHeading.dataId);
}
Expand Down

0 comments on commit 9a284a0

Please sign in to comment.