Skip to content

[number field] Input with aria-hidden focus prevents form submission #3574

@markoffden

Description

@markoffden

Bug report

Current behavior

In some scenarios when submitting a form with Number Field component in it, the following console warning appears and form submit event is not triggered:

Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden.
Element with focus: <input>
Ancestor with aria-hidden: <input> 

Component is used with following format settings:

format={{
    style: 'currency',
    currency: 'EUR',
    currencySign: 'standard',
    currencyDisplay: 'symbol',
    minimumFractionDigits: 2,
    maximumFractionDigits: 2,
}}

A way to reproduce

  1. Set up a basic HTML <form> with Number Field (with Field component wrapper in my case) in it and <button type="submit">.
  2. Input some random number, e.g. 12.
  3. Click somewhere outside the input.
  4. The input gets formatted to 12,00 €.
  5. Comeback to input and edit cents, e.g. 12,33 €.
  6. Try to submit form, submit event is not triggered and above warning appears in browser console.

Expected behavior

Editing Number Field component value should not block form submission

Possible solution

Use inert instead of aria-hidden="true" on "mirror" input.

Base UI version

v1.0.0

Which browser are you using?

Google Chrome 143.0.7499.110

Which OS are you using?

Mac OS Sequoia 15.7.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: number fieldChanges related to the number field component.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions