Critical CSS breaks media library button in CKeditor in D10

Created on 11 August 2023, over 1 year ago
Updated 16 January 2024, 12 months ago

Steps to reproduce

  1. Create a text format with CKeditor enabled and add the Insert media button
  2. Create a new page, edit the body field and click the Insert media button
  3. Nothing happens
  4. Clicking again will pop up the Media library modal, however without the accompanying javascript

Diagnosis

The problem is that getCriticalCss()->isEnabled() will return TRUE for the Insert media button, which is at route /media-library. This is not an admin route (and should not be).

The ajax response after clicking the Insert media button will then contain this:

  {
    "command":"add_css",
    "data":[
      {"id":"critical-css"},
      {"rel":"stylesheet","media":"all","href":"/core/modules/views/css/views.module.css?rz61hm"},
      {"rel":"stylesheet","media":"all","href":"/core/themes/claro/css/components/icon-link.css?rz61hm"},
      {"rel":"stylesheet","media":"all","href":"/core/themes/claro/css/components/media-library.ui.css?rz61hm"},
      {"rel":"stylesheet","media":"all","href":"/core/themes/claro/css/components/views-exposed-form.css?rz61hm"},
      {"rel":"stylesheet","media":"all","href":"/core/themes/claro/css/components/file.css?rz61hm"},
      {"rel":"stylesheet","media":"all","href":"/core/themes/claro/css/theme/media-library.css?rz61hm"}
    ]
  },

Because the "critical-css" entry has no href, ajax.js wil fail on line 1693, leading to this error message from loadjs in the console:

An error occurred during the execution of the Ajax response: TypeError: e is undefined

Proposed resolution

The solution should be in critical_css, not in media_library module. I’m not sure how to proceed though. Should we add a special case to getCriticalCss()->isEnabled() just for the Media library module?

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands gaele

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024