Fix search result links to support opening in new tabs
What does this MR do and why?
This fixes a bug where search result links can't be opened in new tabs/windows.
The problem was due to some analytics tracking we've set up for Elasticsearch. When someone clicks a result, we send that info to Elastic, and that action needs to happen before the regular go-to-the-page-you-clicked-on behavior.
For normal clicks, we want to:
- Prevent the default navigation
- Track analytics
- Navigate to the result page manually (
window.location.href = result.url_path) after sending the analytics event
For modifier (new tab/new window) clicks, we want to:
- Track analytics
- Let the browser's default behavior handle opening in a new tab (so, do not prevent the default navigation -- that was our bug)
This is the same as !361 (merged), but with an additional fix to prevent your current tab from reloading when opening a link in a new tab.
Screenshots, screen recordings, or links to review app
Review app: https://docs.gitlab.com/review-mr-388/
How to set up and validate
Validating locally requires an Elasticsearch API key, but you can validate on the review app like this:
- Enter a search query from the homepage or an interior page, like https://docs.gitlab.com/review-mr-388/topics/plan_and_track
- When results appear, verify that you can navigate to the result in either your current tab, or a new tab.
- Enter another search query and hit
Returnto go to the full results page. - On the full results page, verify that you can navigate to the result in either your current tab, or a new tab.
- Verify that results pagination and filters still work as expected.
Merge request acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this merge request.
Closes #261 (closed)