Problem/Motivation

The media library view mode for Rijksvideo uses the .rijksvideo wrapper and attaches the rijksvideo/rijksvideo library, but its markup is a simple native <video controls> preview. It does not include the custom player element .rijksvideo__video (the video currently uses the legacy class .rijksvideo-element).

rijksvideo.js selects every .rijksvideo element and initialises the custom Video player, which then tries to set volume (and related plugins) on a missing .rijksvideo__video node. That throws a JavaScript error. In AJAX contexts (for example editing a paragraph that embeds Rijksvideo, or opening the media library) this can break the form/dialog instead of only failing the preview.

Steps to reproduce

  1. Install and enable Rijksvideo (2.x / 2.0.0-alpha7 or later).
  2. Create one or more Rijksvideo media items.
  3. Open the media library (for example when selecting media on a content type), or edit an entity/paragraph that shows a Rijksvideo media-library preview via AJAX.
  4. Inspect the browser console (and the AJAX response if the form fails).
  5. Observe a JavaScript error from the custom player when it runs against media-library markup that has .rijksvideo but no .rijksvideo__video.

Proposed resolution

  • Update media--rijksvideo--media-library.html.twig so the media library preview no longer uses the custom player root class or library:
    • Remove attach_library('rijksvideo/rijksvideo').
    • Replace the wrapper class .rijksvideo with .rijksvideo-media-library.
    • Rename the video class from .rijksvideo-element to .rijksvideo-media-library__video.
    • Keep native controls and keep displaying {{ name }}.
  • In rijksvideo.js, skip initialising the custom player when .rijksvideo__video is missing, so incomplete or non-player wrappers cannot crash volume/plugin setup.
  • Leave the default Rijksvideo display template unchanged (.rijksvideo + .rijksvideo__video) so the full accessible player keeps working.

Remaining tasks

  • Confirm the default (non–media-library) Rijksvideo player still works (play, volume, captions, etc.).
  • Confirm media library preview uses native controls, shows the media name, and produces no console errors.
  • Confirm AJAX paragraph / entity edit with a Rijksvideo preview no longer crashes.

User interface changes

Media library Rijksvideo items continue to show a native HTML5 video preview with controls and the media name. The custom Rijksvideo chrome is no longer initialised on that view mode. The default front-end / full media display is unchanged.

API changes

None.

Data model changes

None.

Issue fork rijksvideo-3634295

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

erwinvb created an issue. See original summary.

  • 9d1fee74 committed on 2.x
    Issue #3634295: Prevent custom player attach on media library preview
    
erwinvb’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.