Add support for going back to previous hashes via the browser back button to wiki
This commit is contained in:
		@@ -67,6 +67,9 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
 | 
				
			|||||||
            isHoveringSidebar: false,
 | 
					            isHoveringSidebar: false,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    public componentDidMount() {
 | 
				
			||||||
 | 
					        window.addEventListener('hashchange', this._onHashChanged.bind(this), false);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    public componentWillMount() {
 | 
					    public componentWillMount() {
 | 
				
			||||||
        // tslint:disable-next-line:no-floating-promises
 | 
					        // tslint:disable-next-line:no-floating-promises
 | 
				
			||||||
        this._fetchArticlesBySectionAsync();
 | 
					        this._fetchArticlesBySectionAsync();
 | 
				
			||||||
@@ -74,6 +77,7 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
 | 
				
			|||||||
    public componentWillUnmount() {
 | 
					    public componentWillUnmount() {
 | 
				
			||||||
        this._isUnmounted = true;
 | 
					        this._isUnmounted = true;
 | 
				
			||||||
        clearTimeout(this._wikiBackoffTimeoutId);
 | 
					        clearTimeout(this._wikiBackoffTimeoutId);
 | 
				
			||||||
 | 
					        window.removeEventListener('hashchange', this._onHashChanged.bind(this), false);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    public render() {
 | 
					    public render() {
 | 
				
			||||||
        const menuSubsectionsBySection = _.isUndefined(this.state.articlesBySection)
 | 
					        const menuSubsectionsBySection = _.isUndefined(this.state.articlesBySection)
 | 
				
			||||||
@@ -246,4 +250,8 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
 | 
				
			|||||||
            isHoveringSidebar: false,
 | 
					            isHoveringSidebar: false,
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    private _onHashChanged(event: any) {
 | 
				
			||||||
 | 
					        const hash = window.location.hash.slice(1);
 | 
				
			||||||
 | 
					        sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user