Collapsed Details Element causes JS Error for required fields

Created on 13 January 2023, almost 2 years ago
Updated 27 March 2024, 8 months ago

Problem/Motivation

If you have an empty required field within a collapsed details element, when you submit the form it appears as nothing at all happens.

If you open up chrome Devtools, you will see the following error.
An invalid form control with name='name_of_field'

Steps to reproduce

  1. Create or visit a form with a collapsible details element with a required text field within it
  2. Leave the field empty and ensure the details element is collapsed
  3. Press Submit
  4. Nothing happens
  5. Refer to chrome devtools for error

Proposed resolution

Open the details element for invalid fields being targeted via JS

File: core/misc/details.js

  $('details input[required="required"]').on('invalid', (e) => {
    let $element = $(e.target).parent();
    handleFragmentLinkClickOrHashChange(e, $element);
  });

Remaining tasks

Respond to #19
Resolve comments in the MR

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

Component
FormΒ  β†’

Last updated 1 day ago

Created by

πŸ‡¨πŸ‡¦Canada mdolnik

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024