diff --git a/frontend/src/pages/repo-wiki-mode/main-panel.js b/frontend/src/pages/repo-wiki-mode/main-panel.js index c0956edb27..cb7f5c880c 100644 --- a/frontend/src/pages/repo-wiki-mode/main-panel.js +++ b/frontend/src/pages/repo-wiki-mode/main-panel.js @@ -20,6 +20,7 @@ const propTypes = { lastModified: PropTypes.string, latestContributor: PropTypes.string, permission: PropTypes.string, + hash: PropTypes.string, path: PropTypes.string.isRequired, // whether the file or dir corresponding to the path exist pathExist: PropTypes.bool.isRequired, @@ -82,6 +83,12 @@ class MainPanel extends Component { setTimeout(function() { that.getTitlesInfo(); }, 500); + if (this.props.hash) { + let hash = this.props.hash; + setTimeout(function() { + window.location.hash = hash; + }, 500); + } } switchViewMode = (mode) => { diff --git a/frontend/src/repo-wiki-mode.js b/frontend/src/repo-wiki-mode.js index 35156b8fb6..c326c21098 100644 --- a/frontend/src/repo-wiki-mode.js +++ b/frontend/src/repo-wiki-mode.js @@ -42,6 +42,14 @@ class Wiki extends Component { selectedDirentList: [], }; window.onpopstate = this.onpopstate; + this.hash = ''; + } + + componentWillMount() { + const hash = window.location.hash; + if (hash.slice(0, 1) === '#') { + this.hash = hash; + } } componentDidMount() { @@ -775,6 +783,7 @@ class Wiki extends Component { onItemsMove={this.onMoveItems} onItemsCopy={this.onCopyItems} onItemsDelete={this.onDeleteItems} + hash={this.hash} /> );