Clear previous error messages before displaying new ones

Created on 6 May 2022, over 2 years ago
Updated 10 August 2023, over 1 year ago

Problem/Motivation

I noticed that the method Drupal\media_directories_ui\Controller\MediaDirectoriesController::addMessagesToResponse() will prepend new messages above the browser without clearing the existing ones. This becomes problematic, as with each message the browser gets pushed further down, out of view on the modal. Then when you scroll down, if another is shown, new ones are added to the top and you don't see the new ones. The only way to deal with it currently is to close the modal and reopen it.

Steps to reproduce

  1. Open the browser page or modal.
  2. Perform multiple actions your user does not have access to.
  3. Notice the browser gets pushed down, and new messages are added to the top, out of view.

Proposed resolution

Change the prepend to a replace action.

Remaining tasks

  • Write a patch that performs the intended action.

User interface changes

See above.

API changes

n/a

Data model changes

n/a

🐛 Bug report
Status

Active

Version

2.0

Component

User interface

Created by

🇺🇸United States devkinetic

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.

  • 🇮🇳India dineshkumarbollu

    Hi
    One method is available for clearing the previous messages or error try $this->messenger()->deleteByType('error'); method once calling the $this->messenger()->addError()

Production build 0.71.5 2024