Allow other modules to set readspeaker settings when using POST mode

Created on 11 September 2024, 2 months ago
Updated 17 September 2024, 2 months ago

Problem/Motivation

In our project we needed to set some ReadSpeaker config in window.rsConf. However we also have POST mode enabled. With the POST mode enabled the module adds a JavaScript behavior which sets a setting in window.rsConf without checking if other settings are already set which results in cancelling any other settings.

Proposed resolution

Check if other settings are already set before overriding the entire windows.rsConf property.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇳🇱Netherlands Marty2081

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

Comments & Activities

  • Issue created by @Marty2081
  • 🇳🇱Netherlands Marty2081

    And here is a patch we use to circumvent this problem (maybe someone with proper JS skills has a nicer solution, but this works for us).

  • Status changed to Needs review 2 months ago
  • 🇩🇪Germany sunlix Wesel

    Hey marty2081,

    thank you for this hint. I think this only applies for 1.x.

    In 2.x you can use a hook_preprocess_block() to alter the drupalSettings

    // OpenReadspeakerBlock.php
    '#attached' => [
      'library' => $library,
      'drupalSettings' => [
        'open_readspeaker' => ['rsConf' => $config->get('rsConf')]
      ]
    ]
    

    In 1.x you could also use the libraries-extend / libraries-override mechanic described here: Overriding and extending libraries

  • 🇩🇪Germany sunlix Wesel

    I close this issue due to the stable release of 2.0.0 right now.

    The migration path is there for the Drupal internals except the need of checking the used template.

Production build 0.71.5 2024