Error classes is always removed from checkbox

Created on 19 August 2023, 10 months ago
Updated 29 January 2024, 5 months ago

Problem/Motivation

When Automatically remove error classes when values have been entered setting is enabled, the error class is immediately removed from checkbox elements even if they are not checked.

Steps to reproduce

Navigate to a form with a required checkbox element
Try to submit the form without the checkbox checked
Notice that the error class has been assigned to the checkbox
Trigger "blur" event on the checkbox (in my case it is triggered itself as the form is in a modal)
See the error class has been removed from the checkbox.

Proposed resolution

$().val() returns the value for the checkbox "value" attribute. Therefore it is generally casted to false even if the checkbox is not checked. Check whether the checkbox is checked instead.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Downport

Version

3.0

Component

Code

Created by

🇨🇾Cyprus Alex Bukach

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

Comments & Activities

  • Issue created by @Alex Bukach
  • First commit to issue fork.
  • 🇦🇷Argentina tguerineau

    I've addressed the issue with checkboxes erroneously losing their error classes upon interaction. Here's a brief overview of the fix:

    • Implemented a check for the 'checked' property of checkbox inputs to accurately determine their state.
    • Maintained the existing validation logic for other types of inputs.

    This update ensures that the error class on a checkbox is only removed when the checkbox is actually checked, which aligns with the expected behavior when the 'Automatically remove error classes when values have been entered' setting is enabled.

    The MR contains the necessary adjustments.

    I created a MR for review and would appreciate any feedback.

  • Status changed to Needs review 8 months ago
  • Open on Drupal.org →
    Core: 7.x + Environment: PHP 8.1 & MySQL 5.7
    last update 8 months ago
    Waiting for branch to pass
  • @tguerineau opened merge request.
  • Issue was unassigned.
  • Status changed to Downport 5 months ago
  • 🇮🇳India Nitesh Sethia

    The last patch added to the issue queue is working as expected.

  • 🇮🇳India Nitesh Sethia

    Quick screenshot of the Error.

Production build 0.69.0 2024