Problem/Motivation

When changing background color of a section in the sidebar, the change does not reflect on the page unless the Update button is pressed.

Steps to reproduce

  1. Install latest version of Drupal 10 (currently 10.3.2).
  2. Install bootstrap_styles, bootstrap_layout_builder, and layout_builder_blocks.
  3. Create a new content type and enable Layout Builder for its default view display mode.
  4. Add Bootstrap 1 Col section and create a content block with sample text in it.
  5. Press "Configure Section ...", and on Style tab set any background color.

Expected behavior

Background color of the section get updated right after clicking any option in the Background color list.

Actual behavior

Background color of the section does not get updated when options in the Background color list are clicked, until the Update button is pressed. Also, if any background color was already selected for the section, it gets removed from the section until the Update button is pressed.

Proposed resolution

Fix logic for checking if the background type is image or video.

Current logic checks if $group_elements['background_video'] or $group_elements['background_image'] is not an empty string. This check always passes since these elements are arrays. This causes the video background to be incorrectly recognized when only the background color is set.

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

iamweird created an issue. See original summary.

iamweird’s picture

Issue summary: View changes
iamweird’s picture

I'm not sure if old check of $group_elements['background_image'] and $group_elements['background_video'] for empty string is ever valid or should be preserved for a historical reason e.g. to make layouts made with previous versions work correctly.

However, I decided to change check here to is_numeric instead of comparison with empty string to better reflect actual expectation of a media ID. Advice on this matter is welcome from anyone who knows the module architecture well.

iamweird’s picture

Status: Active » Needs review