Skip to content

onBlur at single field level in material ui #2384

Open
@priyankapyt

Description

@priyankapyt

Prerequisites

Description

Requirement
Actually I want to implement onBlur feature for every single field in my form.

What I'm doing:
I'm able to achieve onBlur validation -> using ObjectFieldTemplate and passing onBlur at every item level explicitly.
and, Inside my onBlur function, after validation -> I'm setting the extraErrors using setState.

I have added screenshot of my implementation as first comment in thread.

Issue:
So since state is getting update -> the next field in form is loosing its focus. This is where I'm blocked now.
Do we have a better way of achieving the same or what might be going wrong that my form is loosing focus.

Steps to Reproduce

  1. Create form with '@rjsf/material-ui'
  2. use ObjectFieldTemplate to render fields.
  3. Inside ObjectFieldTemplate function -> add onBlur function and inside that set the state of extraErrors

Expected behavior

On state update -> field shouldn't loose its focus

Actual behavior

Focus is getting lost when I update the errors using onBlur

Version

2.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions