Page MenuHomePhabricator

[Production Commons] MediaSearch Quickview does not display if an alternative language has been set (anon users)
Closed, ResolvedPublicBUG REPORT

Description

For logged-out users, Commons uses a script called AnonymousI18N.js instead of the Universal Language Selector to provide language-switching functionality (logged-in users get ULS).

When this script is active, it breaks the QuickView functionality on our experimental Special:MediaSearch page by injecting its own behavior (which is to navigate the user to the target page with the appropriate language params added to the URL):

// Prevent the default linking functionalty and instead use getUrlForLanguage()
e.preventDefault();
location.href = AnonymousI18N.getUrlForLanguage(href_full, wgAnonUserLanguage);

We want links in the MediaSearch results grid to have a different behavior. Rather than immediately taking the user to a new page, we want them to open a "quickview" sidebar which shows a preview of the given media file in-place. But we still want to use link elements here so that the user can control-click to open a result in a new tab, etc.

Since this is an on-wiki script, I've added a proposal on the relevant talk page to add support for disabling on specific pages (maybe through a JS config var or similar): https://commons.wikimedia.org/wiki/MediaWiki_talk:AnonymousI18N.js#Allow_specific_pages_to_disable_this_script

Steps to Reproduce:
Perform a media search in a non-English language as an anonymous user, for example:
https://commons.wikimedia.org/wiki/Special:MediaSearch?type=bitmap&quickview=true&q=cat&debug=true&uselang=de

Make sure to let the page JS fully load; this can take extra time with debug mode on, and click an image result.

Actual Results:
The user is taken directly to the File page of the clicked result.

Expected Results:
The QuickView element should appear on the right-hand side of the same page. Compare with what happens when you search in the default language:

https://commons.wikimedia.org/wiki/Special:MediaSearch?type=bitmap&quickview=true&q=cat&debug=true

QA Notes

This patch will be live on Production commons next Wednesday (August 19), assuming the train goes out as it normally would. At that point, we should be able to test if users of the AnonymousI18N.js language switcher are able to see the Quickview normally (quickview=true params will still need to be present in the URL of course).

Instructions for testing (once patch is live):

  • Navigate to Special:MediaSearch page (with quickview=true url params: https://commons.wikimedia.org/wiki/Special:MediaSearch?quickview=true
  • Ensure you are logged out
  • Make a search and click on an Image, Audio, or Video result (category results do not have QuickView enabled); the Quickview panel should appear
  • Try switching the language by 1) using the drop-down menu in the sidebar, or 2) adding the uselang=whatever params directly to the URL
  • Try clicking on a search result after the language has been changed; QuickView should still appear

Event Timeline

egardner renamed this task from [Production Commons] Quickview does not display if an alternative language has been set to [Production Commons] Quickview does not display if an alternative language has been set (anon users).Aug 12 2020, 4:35 PM
egardner updated the task description. (Show Details)

Some additional information about this bug:

  1. Quickview does work for logged-in Commons users who switch languages using the Universal Language Selector tool. Example:
    Screen Shot 2020-08-12 at 9.31.13 AM.png (2×3 px, 3 MB)
  2. Logged-out Commons users don't actually see the ULS widget at all; there is a different feature for language-switching that anonymous users see on production Commons. Apparently this may change soon, there is an in-progress ticket to provide the ULS to all users on Commons: https://phabricator.wikimedia.org/T161517.
  3. If an anonymous user clicks on a search result, an mw.Api error gets thrown in the console but no reason is provided.

It seems that the API request to load the quickview data is failing for anon users for some reason (which may have to do with the custom language switcher?), so the default "go to the search result page" behavior is happening instead.

egardner renamed this task from [Production Commons] Quickview does not display if an alternative language has been set (anon users) to [Production Commons] MediaSearch Quickview does not display if an alternative language has been set (anon users).Aug 12 2020, 4:58 PM

Here's another follow-up. It looks like the code we've written in the Mediasearch UI is working fine – if I programmatically trigger the "showDetails" method of the SearchResults component using the Vue inspector, I can actually load the Quickview just fine as a logged-out user (in any language):

Screen Shot 2020-08-12 at 10.40.05 AM.png (1×2 px, 2 MB)

The problem is, the custom language selector widget that anonymous users get on Commons is hijacking the link elements with its own event listener (presumably this is to ensure that links the users follows get the appropriate language URL query params added?):

Screen Shot 2020-08-12 at 10.46.51 AM.png (1×3 px, 2 MB)

The first event listener here comes from a script called MediaWiki:AnonymousI18N.js. Pretty sure this is what's keeping QuickView from loading in this situation.

Change 619838 had a related patch set uploaded (by Eric Gardner; owner: Eric Gardner):
[mediawiki/extensions/WikibaseMediaInfo@master] Stop event propagation from search results click events

https://gerrit.wikimedia.org/r/619838

Change 619838 merged by jenkins-bot:
[mediawiki/extensions/WikibaseMediaInfo@master] Stop event propagation from search results click events

https://gerrit.wikimedia.org/r/619838

Etonkovidova subscribed.

Checked in commons wmf.5

  • Images, Audio, Video files are displayed correctly in Quickview when url parameter changed or when a selection of a language is made in the sidebar menu.