removeAttr does not uncheck checkboxes in the resetFields function

Created on 17 August 2023, over 1 year ago
Updated 3 September 2023, over 1 year ago

1.0 Problem/Motivation
We have a webform_civicrm form with an Existing Contact field for Organizations, and a set of checkboxes for Type of Organization. If I search for one contact and select them, then press the "x" to remove them and search for another contact, the checkboxes which were auto-filled for the first contact are not unchecked.

2.0 Detailed steps to reproduce (embed screenshots)

  • Create a new webform with CiviCRM processing enabled
  • In the CiviCRM tab, set Number of contacts: 1
  • Set the contact type to Organization
  • Set the Type of Organization to User Select
  • Save settings
  • Switch to the Build tab
  • Edit the Existing Contact element, and change Form Widget to Autocomplete, then save
  • View the form
  • Search for a contact with one or more selections in Type of Organization
  • Select the contact, and observe that Type of Organization checkboxes are filled
  • Press the 'x' in the Existing Contact box to clear the selection
  • Observe that Type of Organization checkboxes are still filled
  • Search for another contact with different Type of Organization settings, then select them
  • Observe that the original set of Type of Organization checkboxes are still filled, plus the new ones for the second contact

3.0 Proposed resolution
Locally, I was able to fix the issue by changing this line:

https://git.drupalcode.org/project/webform_civicrm/-/blob/6.x/js/webform...

To this:

$(this).prop('checked', false).trigger('change', 'webform_civicrm:reset');

From my reading, it seems that removeAttr no longer changes the corresponding property as of jQuery 3:

https://stackoverflow.com/questions/6169826/propchecked-false-or-removea...

Tested on Drupal 9.5.9 with jQuery 3.6.3 and webform_civicrm 6.2.4.

🐛 Bug report
Status

Fixed

Version

6.2

Component

CiviCRM Data Handling

Created by

🇦🇺Australia jude.hungerford

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

Comments & Activities

Production build 0.71.5 2024