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

Screencast of the creation of a block

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

carolpettirossi created an issue. See original summary.

carolpettirossi’s picture

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"

carolpettirossi’s picture

Status: Active » Needs review
gab.’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new780.11 KB

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!

kmonty’s picture

Status: Reviewed & tested by the community » Needs work

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.)

shalini_jha’s picture

Status: Needs work » Needs review
StatusFileSize
new499 bytes

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

kmonty’s picture

Status: Needs review » Needs work

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.

olegrymar made their first commit to this issue’s fork.

Updated MR. Added the missing once argument.

olegrymar’s picture

Status: Needs work » Needs review