question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling blur method on TextInput does not trigger the onBlur handler

See original GitHub issue

I am calling the blur method on a TextInput component on the componentDidMount event like so:

componentDidMount() {
        this.refs.txtInput.blur();
    }

However the onBlur handler that is assigned to this textinput component is not triggered as a result. Do I have the correct expectation or this is not the case.

I have tried calling blur from other methods as well still it does not trigger the handler.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
idecommented, Aug 25, 2015

If the text field already doesn’t have focus (which it probably doesn’t when first mounted) then blur does nothing.

0reactions
Nosherwancommented, Jun 18, 2016

No I had a workaround for validation of all fields on a page where a separate button would trigger validation and would take the user to previous page.

On Sun, 19 Jun 2016, 12:55 AM Žiga Vukčevič notifications@github.com wrote:

@Nosherwan https://github.com/Nosherwan did you find a solution for this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/2432#issuecomment-226946621, or mute the thread https://github.com/notifications/unsubscribe/AAIc-Rn2ZuQK4QHMkCK51BIEM7MnnlYNks5qNAbigaJpZM4FxveT .

Read more comments on GitHub >

github_iconTop Results From Across the Web

onblur event is not firing - javascript - Stack Overflow
To have Onblur on an element it should receive focus first, Div elements don't receive focus by default. You can add tabindex="0"
Read more >
react-hook-form controlled input onblur doesn't work - You.com
In your code, the form mode is onBlur . it means the validation is triggered on blur event (unfocus the input). When you...
Read more >
onblur Event - W3Schools
The onblur event occurs when an element loses focus. The onblur event is often used on input fields. The onblur event is often...
Read more >
Element: blur event - Web APIs | MDN
The blur event fires when an element has lost focus. The event does not bubble, but the related focusout event that follows does...
Read more >
Client-side Checking with React.js JSX Events Using onBlur
onBlur triggers when focus is lost from the input element in context. In React.js, we bind event handlers by passing a method defined...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found