Skip to content

First required field in form skips validation until user interaction #3915

@summer-barbie

Description

@summer-barbie

Describe the bug

I have 4 required fields in the enrollment form. When the form renders, the first input field receives focus. When I don't type anything and click away from it, it doesn't show the expected validation error ("This field cannot be left blank").

I've tested this by changing the order of the fields, and this behavior is always present for whichever field appears first: no matter how many times the first input is clicked and then blurred, its validation is not triggered.

I've found this code in BaseForm.js, which i suspect is the culprit:

    if (oktaUnderscore.isEmpty(this.getInputs().toArray())) {
      oktaUnderscore.extend(inputsOptions[0], {
        validateOnlyIfDirty: true
      });
    }

Reproduction Steps

  1. Create an enrollment form with the first field set as required
  2. Render the form (the first field automatically receives focus)
  3. Without entering any data, click away from the first field (blur the field)

Expected behavior: The first field should display a validation error ("This field cannot be left blank")
Actual behavior: No validation error is shown on the first field

SDK Versions

System:
OS: macOS 26.0.1
CPU: (12) arm64 Apple M3 Pro
Memory: 352.58 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.7.3 - /Users//.nvm/versions/node/v21.7.3/bin/node
npm: 10.5.0 - /Users//.nvm/versions/node/v21.7.3/bin/npm
Browsers:
Brave Browser: 141.1.83.109
Chrome: 142.0.7444.60
Firefox: 143.0.1
Safari: 26.0.1
npmPackages:
@okta/okta-auth-js: ^7.14.0 => 7.14.0
@okta/okta-signin-widget: ^7.37.0 => 7.37.0
@okta/okta-vue: ^5.8.0 => 5.8.0

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions