• Resolved iexos

    (@iexos)


    When creating a conditionally shown required text input field, it is impossible to finish the order if it is hidden (and empty).

    This seems to be because of browser-level validation which is still active for fields that are hidden.

    I got it to work with this LLM-assisted code:

    export function applyVisibility( fieldEl, visible ) {
    if ( visible ) {
    fieldEl.classList.remove( 'pkset-hidden' );
    } else {
    fieldEl.classList.add( 'pkset-hidden' );
    }

    // Native browser validation runs before the form's submit handler.
    // A required control inside a hidden field can therefore block submission.
    const controls = fieldEl.querySelectorAll(
    'input, select, textarea'
    );

    controls.forEach( ( control ) => {
    // Remember the original required state so it can be restored.
    if (
    ! control.hasAttribute( 'data-pkset-original-required' ) &&
    control.required
    ) {
    control.setAttribute(
    'data-pkset-original-required',
    'yes'
    );
    }

    if ( ! visible ) {
    control.required = false;
    } else if (
    control.getAttribute( 'data-pkset-original-required' ) ===
    'yes'
    ) {
    control.required = true;
    }
    } );
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter iexos

    (@iexos)

    Works with 1.1.2, thank you!

    Plugin Support Zavian Reed

    (@zavian)

    Hi @iexos,

    First of all, apologies for the late reply, and thank you for reporting this issue and sharing your workaround. We really appreciate your patience and help in identifying the cause.

    Version 1.1.2 is now available with a fix for this issue! 🎉

    Here’s what we’ve fixed:

    • Hidden fields no longer trigger the browser’s native required validation, and validation is restored when the fields become visible again.
    • Required fields inside hidden Sections are now handled correctly and no longer block the order submission.

    Required fields that are visible will continue to work as expected.

    Please update to version 1.1.2 and remove your custom JavaScript workaround, as it should no longer be necessary.

    Thanks again for bringing this to our attention! If you encounter any further issues, please let us know. We’ll be happy to help.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.