Error classes is always removed from checkbox

Created on 19 August 2023, over 1 year ago
Updated 13 September 2024, 2 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

Closed: won't fix

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 about 1 year ago
  • Open on Drupal.org →
    Core: 7.x + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    Waiting for branch to pass
  • @tguerineau opened merge request.
  • Issue was unassigned.
  • Status changed to Downport 10 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.

  • Status changed to Closed: won't fix 2 months ago
Production build 0.71.5 2024