Page MenuHomePhabricator

WordPress Wikipedia Preview applies styles but tooltips don't appear
Closed, ResolvedPublic1 Estimated Story PointsBUG REPORT

Description

Describe the Issue

Wikipedia Preview correctly applies CSS styling to elements with class="wmf-wp-with-preview", but tooltips do not appear when hovering over them.

This happens even when the span is hardcoded (so not as a result of the site being multilingual) into the template, meaning the issue is not related to dynamically generated content.

Steps to Reproduce
  1. Install the latest Wikipedia Preview WordPress plugin (v1.14.3).
  2. Add this hardcoded span inside any post or template file (index.php or a post editor block): `html <span data-wp-title="Vrije kennis" data-wp-lang="nl" class="wmf-wp-with-preview wiki">vrije kennis</span>
  3. Load the page and hover over "vrije kennis".
  4. The element has Wikipedia Preview styling, but no tooltip appears.
Expected Behavior

Clicking the Wikipedia Preview-enabled span should display a tooltip with content from Wikipedia.

Console Errors

There's a mysterious version difference in the console: "Wikipedia Preview - version 1.12.4 (26e7a880)" is printed as a "script is loaded" sort of message, but then when you run wikipediaPreview.init(); in the console you get the error:

wikipedia-preview.js?ver=1.14.3:102 Uncaught TypeError: Cannot read properties of undefined (reading 'root')

`at Object.Zs [as init] (wikipedia-preview.js?ver=1.14.3:102:970)`
`at <anonymous>:1:18`
    1. Technical Details
  • WordPress Version: 6.x
  • Wikipedia Preview Version: 1.14.3
  • Browser: Chrome
  • Theme: Typesolid
Additional Context

The issue occurs even when auto-detection is disabled (wikipediapreview_enabled_post_types returns an empty array).
Manually calling wikipediaPreview.init() does not resolve the issue.
MutationObserver detects content changes, but tooltips still do not appear.

Event Timeline

Nemoralis renamed this task from Bug Report: WordPress Wikipedia Preview applies styles but tooltips don't appear (plugin version 1.14.3) to WordPress Wikipedia Preview applies styles but tooltips don't appear.Jan 31 2025, 11:40 PM
Nemoralis added a project: Wikipedia-Preview.
Nemoralis updated the task description. (Show Details)

@Aklapper Can you tell me the repo to which this task belongs?

@RJ2904: Hi, not sure why you ask only me? Please see "Tags" in the sidebar and https://www.mediawiki.org/wiki/New_Developers#Communication_tips - thanks!

The console message shows the version of the Wikipedia Preview core component, which is at 1.12.4, while the Wikipedia Preview Wordpress plugin (a wrapper around the code component) is at 1.14.3. It is certainly confusing and I apologize for that.

The hardcoded span requires the data-wikipedia-preview valueless attribute to be found. Here's the updated example:

<span data-wikipedia-preview data-wp-title="Vrije kennis" data-wp-lang="nl" class="wmf-wp-with-preview wiki">vrije kennis</span>

Calling wikipediaPreview.init(); again shouldn't be needed but if you do, please provide a config object as the only parameter to the function. See documentation for available config options.

Nikerabbit set the point value for this task to 1.Feb 4 2025, 9:41 AM