Commit faf0f639 authored by Phil Hughes's avatar Phil Hughes

Fixes blob view not updating highlighted line after hash change

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/213212
parent 05679ecf
......@@ -54,6 +54,7 @@ LineHighlighter.prototype.bindEvents = function() {
$fileHolder.on('click', 'a[data-line-number]', this.clickHandler);
$fileHolder.on('highlight:line', this.highlightHash);
window.addEventListener('hashchange', e => this.highlightHash(e.target.location.hash));
};
LineHighlighter.prototype.highlightHash = function(newHash) {
......
......@@ -67,6 +67,16 @@ describe('LineHighlighter', function() {
expect(func).not.toThrow();
});
it('handles hashchange event', () => {
const highlighter = new LineHighlighter();
spyOn(highlighter, 'highlightHash');
window.dispatchEvent(new Event('hashchange'), 'L15');
expect(highlighter.highlightHash).toHaveBeenCalled();
});
});
describe('clickHandler', function() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment