A keyCode is not sent from CKEditor 5 FunctionalJavaScript test to JavaScript

Created on 7 July 2025, 8 days ago

Problem/Motivation

The ckeditor5.admin.js recieves keyCode value from a KeyboardEvent for Safari focus problem. In fact, web browsers such as Chrome and Safari and so on send keyCode value on a KeyboardEvent and work this JavaScript code when a "ArrowUp" is pressed.
But CKEditor5TestBase->triggerKeyUp() method which is used some of CKEditor5 FunctionalJavaScript tests, sends only key value on a KeyboardEvent(). Therefore, JavaScript code which fix Safari focus problem doesn't work on a FunctionalJavaScript test.

Steps to reproduce

Change code as follows and run FunctionalJavaScript test.

/core/modules/ckeditor5/js/ckeditor5.admin.js

      once('safari-focus-fix', '.ckeditor5-toolbar-item').forEach((item) => {
        item.addEventListener('keydown', (e) => {
          
          // Add two below lines.
          drupalSettings.keyTest = drupalSettings.keyTest ?? [];
          drupalSettings.keyTest.push(e.keyCode);
          // Add two above lines.
          
          const keyCodeDirections = {
            9: 'tab',
            37: 'left',
            38: 'up',
            39: 'right',
            40: 'down',
          };

/core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingTest.php

    $this->assertNotEmpty($assert_session->waitForElement('css', '.ckeditor5-toolbar-item-sourceEditing'));
    $this->triggerKeyUp('.ckeditor5-toolbar-item-sourceEditing', 'ArrowDown');
    // Add a below line.
    print_r($this->getDrupalSettings()['keyTest']);
    // Add a above line.
    $assert_session->assertWaitOnAjaxRequest();

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

ckeditor5.module

Created by

🇯🇵Japan tom konda Kanagawa, Japan

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

Comments & Activities

Production build 0.71.5 2024