Move 'Webform repair configuration' to a dedicated confirmation form/page.

Created on 26 February 2024, 9 months ago
Updated 25 April 2024, 7 months ago

Problem/Motivation

I accidentally ran the "Repair configuration" process by pressing the Enter key and expected, that the form was submitted. I don't know which side effects this process has, but I guess, that some precious config would be lost now.

The "Repair" button is also dangerously close to the "Save configuration" button, so it can be easily clicked by accident.

Steps to reproduce

* go to admin/structure/webform/config/advanced
* click a checkbox (now the input has focus)
* press Enter key
* because the form has 2 inputs of type submit, the first in the DOM is chosen, which is the repair button

Not sure, if this would change anything, but all JS libraries are disabled to avoid loading data from CDNs without consent and to avoid bloat.

Proposed resolution

* use 2 different forms or
* move the repair button below the save button as a quick and dirty workaround or
* make sure to confirm the repair process - see: https://www.drupal.org/docs/drupal-apis/form-api/confirmformbase-to-conf... โ†’

Either way. The form shouldn't have multiple submit buttons.

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Fixed

Version

6.2

Component

User interface

Created by

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

Merge Requests

Comments & Activities

  • Issue created by @raffaelj
  • removed a line break in initial post that caused ugly markup

  • I had another look. This time with an open dev console in my Firefox and many errrors. For some reason the errors are only on the English version, not in the German one.

    Uncaught TypeError: drupalSettings.user is undefined
         http://localhost:8080/core/modules/contextual/js/contextual.js?v=10.2.3:23
         http://localhost:8080/core/modules/contextual/js/contextual.js?v=10.2.3:314
    contextual.js:23:27
    Uncaught TypeError: Drupal.contextual is undefined
         http://localhost:8080/core/modules/contextual/js/models/StateModel.js?v=10.2.3:17
         http://localhost:8080/core/modules/contextual/js/models/StateModel.js?v=10.2.3:130
    StateModel.js:17:49
    Uncaught TypeError: Drupal.contextual is undefined
         http://localhost:8080/core/modules/contextual/js/views/AuralView.js?v=10.2.3:11
         http://localhost:8080/core/modules/contextual/js/views/AuralView.js?v=10.2.3:59
    AuralView.js:11:47
    Uncaught TypeError: Drupal.contextual is undefined
         http://localhost:8080/core/modules/contextual/js/views/KeyboardView.js?v=10.2.3:11
         http://localhost:8080/core/modules/contextual/js/views/KeyboardView.js?v=10.2.3:62
    KeyboardView.js:11:50
    Uncaught TypeError: Drupal.contextual is undefined
         http://localhost:8080/core/modules/contextual/js/views/RegionView.js?v=10.2.3:11
         http://localhost:8080/core/modules/contextual/js/views/RegionView.js?v=10.2.3:75
    RegionView.js:11:48
    Uncaught TypeError: Drupal.contextual is undefined
         http://localhost:8080/core/modules/contextual/js/views/VisualView.js?v=10.2.3:11
         http://localhost:8080/core/modules/contextual/js/views/VisualView.js?v=10.2.3:109
    VisualView.js:11:48
    Uncaught TypeError: drupalSettings.path is undefined
         http://localhost:8080/core/modules/toolbar/js/toolbar.menu.js?v=10.2.3:15
         http://localhost:8080/core/modules/toolbar/js/toolbar.menu.js?v=10.2.3:256
    toolbar.menu.js:15:31
    Uncaught TypeError: pathInfo is undefined
         http://localhost:8080/core/modules/toolbar/js/escapeAdmin.js?v=10.2.3:16
         http://localhost:8080/core/modules/toolbar/js/escapeAdmin.js?v=10.2.3:45
    escapeAdmin.js:16:5
    Unknown property โ€˜enable-backgroundโ€™.  Declaration dropped. advanced:1:19
    Unknown property โ€˜-moz-osx-font-smoothingโ€™.  Declaration dropped. advanced:1:3006
    Uncaught TypeError: path is undefined
        attach http://localhost:8080/core/misc/active-link.js?v=10.2.3:25
        attachBehaviors http://localhost:8080/core/misc/drupal.js?v=10.2.3:166
        attachBehaviors http://localhost:8080/core/misc/drupal.js?v=10.2.3:162
         http://localhost:8080/core/misc/drupal.init.js?v=10.2.3:32
        listener http://localhost:8080/core/misc/drupal.init.js?v=10.2.3:20
        domReady http://localhost:8080/core/misc/drupal.init.js?v=10.2.3:26
         http://localhost:8080/core/misc/drupal.init.js?v=10.2.3:31
         http://localhost:8080/core/misc/drupal.init.js?v=10.2.3:34
    active-link.js:25:42
    Uncaught SyntaxError: "" string literal contains an unescaped line break advanced:1:88

    Some broken HTML markup caused all the contextual errors.

    web/modules/contrib/webform/src/Form/AdminConfig/WebformAdminConfigAdvancedForm.php

    Line 103 (unclosed "a" tag):

    - 'This behavior is disabled when the <a href=":href">Tippy.js library is disabled</a.'
    + 'This behavior is disabled when the <a href=":href">Tippy.js library is disabled</a>'
    

    Of course now the German translation is missing, because it was translated from the broken markup, but with correct closing tag. Now also all the fancy options aren't displayed italic anymore. Nice.

    Now I'm left with

    Uncaught SyntaxError: "" string literal contains an unescaped line break advanced:1:88

    in the English and the German version.

    web/modules/contrib/webform/src/Form/AdminConfig/WebformAdminConfigAdvancedForm.php

    Line 319:

    - . PHP_EOL
    + . '\r\n'
    

    Now both, the English and the German page ask for confirmation (with line break). Pressing the Enter key triggers that confirmation message.

    This only fixes the broken HTML. Triggering the confirm alert prevents damage, but is completely out of context. The actual issue should be resolved by moving the repair step into a different form.

    This also shows why relying purely on JavaScript isn't the best idea. It can break and than native HTML should do the job.

    Side note: This broken code is just another example why enabling all JS libraries by default is a bad idea and enabling CDN usage by default is an even worse idea.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jrockowitz Brooklyn, NY

    Let's move the repair to a confirmation page.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jrockowitz Brooklyn, NY
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.4 + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    536 pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jrockowitz Brooklyn, NY
  • Pipeline finished with Success
    8 months ago
    Total: 2095s
    #138090
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.4 + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    536 pass
  • Pipeline finished with Skipped
    8 months ago
    #140266
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.4 + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    536 pass
  • Pipeline finished with Skipped
    8 months ago
    #140267
  • Status changed to Fixed 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jrockowitz Brooklyn, NY
  • Pipeline finished with Success
    8 months ago
    Total: 2019s
    #140265
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jrockowitz Brooklyn, NY
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • I had a quick look using the dev release. Now pressing Enter works as expected and the repair button is much more understandable with the added context. Thanks for the fix.

Production build 0.71.5 2024