Default value of 'No Slots Available Message' not displayed

Created on 12 January 2025, 3 months ago

Problem/Motivation

The "No slots available message" field in the element configuration does not display its default value ("No slots available.") on the form. If the default value is changed to any other value, the message is correctly displayed when no slots are available for a selected day.

Steps to reproduce

  1. Add an "Appointment Booking" element to a webform.
  2. Leave the default value of the "No slots available message" configuration field unchanged.
  3. Book all available slots for a specific day.
  4. Observe that the message "No slots available." is not displayed on the form.

Proposed resolution

In the WebformBooking.php file, within the prepare() function (around line 456), an empty string is currently passed to the JavaScript DrupalSettings object when the element's #no_slots value is empty or unset:

'noSlots' => $element['#no_slots'] ?? '',

In webform_booking.js (around line 20), if the noSlots variable is empty, the default message "No slots available" is expected to display:

const noSlots = elementConfig.noSlots ?? 'No slots available';

However, since an empty string is passed to noSlots instead of NULL, only the empty string is displayed, and the default message is not shown as intended.

Fix:

Update the code in the prepare() function to pass NULL instead of an empty string:

'noSlots' => $element['#no_slots'] ?? NULL,
🐛 Bug report
Status

Active

Version

1.1

Component

Code

Created by

🇦🇹Austria electric.larry Vienna

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024