Creating a block with form errors should scroll the modal to the messages area

Created on 20 July 2023, over 1 year ago
Updated 30 December 2023, 11 months ago

Problem/Motivation

When the user tries to create a block that contains errors, they should be automatically scrolled to the top of the modal showing the messages.
Currently, they see nothing, and they need to scroll manually to the top.

Steps to reproduce

Click to create a custom block
Don't fill any field
Click to Add/Create the block

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇧🇷Brazil carolpettirossi Campinas - SP

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

Comments & Activities

  • Issue created by @carolpettirossi
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    5 pass
  • @carolpettirossi opened merge request.
  • 🇧🇷Brazil carolpettirossi Campinas - SP

    Attaching .patch to use with composer.json

    MR is ready to review. Note that the code only works if the messages div has "role=alert"

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    5 pass
  • Status changed to RTBC about 1 year ago
  • 🇵🇭Philippines Zed9

    Hi @carolpettirossi I've reviewed your patch (3375915-creating_block_form_errors_scroll-3.patch) and can confirm the modal scrolls up when an error on the form occurs. Please refer to the attached image for reference. Appreciate your efforts!

  • Status changed to Needs work 11 months ago
  • 🇺🇸United States kmonty San Francisco, CA

    Minor change, but the `once` dependency should be included in the wrapper function.

    So:

    (function (Drupal, drupalSettings) {
    [...]
    })(Drupal, drupalSettings);
    

    becomes:

    ((Drupal, drupalSettings, once) => {
    [...]
    })(Drupal, drupalSettings, once);
    

    Also, this should be run through eslint, as it doesn't match Drupal's Prettier rules (single quotes instead of double quotes, no unnamed funcs, incomplete code comments // If no error messages exist, the etc.)

  • Status changed to Needs review 11 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update 11 months ago
    Patch Failed to Apply
  • 🇮🇳India shalini_jha

    Hi, I have updated the changes in this patch. please review.

  • Status changed to Needs work 11 months ago
  • 🇺🇸United States kmonty San Francisco, CA

    The new patch is just for my suggested changes against the 8.x branch and not updating the existing patch. It also does not include eslint changes.

Production build 0.71.5 2024