Olivero: Messages can be malformed when JS creates messages and PHP messages already exist

Created on 12 July 2021, almost 3 years ago
Updated 6 June 2023, about 1 year ago

Problem/Motivation

Split off from #3212975: Olivero: Normalize JavaScript selectors in messages.es6.js β†’

I'm noticing something a bit strange regarding the messages.

Everything works fine when messages are added in from PHP or from JS via Drupal.Message, but JS messages added in when PHP messages are already present are not properly placed. Screenshots are attached. All messages close as expected, and "nested" messages close when their parent is closed.

Steps to reproduce

1. Make sure Olivero is the default frontend theme.

2. Apply patch to latest 9.4.x. Note there are 2 patches (one for D9 and one for D10).

3. Add status/warning/error messages via PHP. In olivero.theme's preprocess_html function:

$messenger = Drupal::messenger();
$messenger->addStatus('PHP Status message');
$messenger->addWarning('PHP Warning message');
$messenger->addError('PHP Error message');

4. Confirm messages display & close properly.

5. Add the core drupal.message library to Olivero's olivero.info.yml libraries

libraries:
  - olivero/global-styling
  - core/drupal.message

6. Clear the cache.

7. Refresh page and add messages via javascript in the console:

const messenger = new Drupal.Message;
messenger.add('js status message', {type: 'status'});
messenger.add('js error message', {type: 'error'});

8. Confirm all messages are displayed & close properly.

Proposed resolution

Update the code to handle messages coming from both PHP and JavaScript at the same time.

Remaining tasks

  1. Test patch
  2. Commit

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Fixed

Version

9.4

Component
OliveroΒ  β†’

Last updated about 10 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States mherchel Gainesville, FL, US

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.

Production build 0.69.0 2024