Alert "CodeMirror library is not loaded" is not a good UX.

Created on 1 May 2019, almost 6 years ago
Updated 4 March 2023, almost 2 years ago

Problem/Motivation

There is an alert message "CodeMirror library is not loaded!" which shows up when can't find the library.

The problem is in that when you have CodeMirror editor selected for specific text formatter, and it does not default for the textarea on the page, this alert shows up. When you select the format with codemirror, all works as expected. So this alert is not necessary for the user.

Proposed resolution

Do not show this message in alert, use console.log instead or equivalent.

Maybe this alert needs to be only shown when there is at least one element of textarea[data-codemirror] on the page. Since if the format is not selected, the library is loaded, but element at this moment is not presented on the page.

For example:

    attach: function () {
      var $textAreas = $('textarea[data-codemirror]').once('codemirror-editor');

      if (typeof CodeMirror === 'undefined' && $textAreas.length && warn) {
        alert(Drupal.t('CodeMirror library is not loaded!'));
        warn = false;
        return;
      }

      $.each($textAreas, function (key, textArea) {
        init(textArea);
      });
    },

Remaining tasks

- Think about how to solve this better.
- Patch.

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇷🇺Russia niklan Russia, Perm

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024