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,
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

electric.larry created an issue. See original summary.

electric.larry’s picture

Here's a patch that should fix issue #3499252.

electric.larry’s picture

Assigned: electric.larry » Unassigned
Status: Active » Needs review
rfmarcelino’s picture

Thank you @electric.larry .
Tested. Merging the MR.

rfmarcelino’s picture

Status: Needs review » Fixed
rfmarcelino’s picture

Status: Fixed » Closed (fixed)