react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

TextInput's onFocus and onBlur functions are not being executed

Open jagorrin opened this issue 6 years ago • 8 comments

Environment

  1. react-native -v: react-native-cli: 2.0.1 react-native: 0.60.6
  2. npm ls rnpm-plugin-windows: [email protected]
  3. npm ls react-native-windows: [email protected]
  4. node -v: v10.15.0
  5. npm -v: 6.13.1

Then, specify:

  • Target Platform Version(s): 10.0.18362.0
  • Target Device(s): Desktop
  • Visual Studio Version: 2017
  • Build Configuration: Debug

Steps to Reproduce

  1. Create a TextInput in a project using React Native Windows
  2. Supply an onFocus and onBlur function to the TextInput
  3. Launch the app and focus or blur the TextInput
  4. Observe that the code in the onFocus and onBlur provided to the TextInput is not executed

Example code:

import * as RN from "react-native";

render() {
    return (
          <RN.TextInput onFocus={this._onFocus} onBlur={this._onBlur} />
     );
}

_onFocus = (event: RN.NativeSyntheticEvent<RN.TextInputFocusEventData>) => {
     ...
}

_onBlur = (event: RN.NativeSyntheticEvent<RN.TextInputFocusEventData>) => {
     ...
}

Expected Behavior

I expected the code in the _onFocus and _onBlur functions to be executed.

Actual Behavior

The code in the _onFocus and _onBlur functions was not executed.

jagorrin avatar Jan 03 '20 21:01 jagorrin

@licanhua You implemented focus and blur. Were the callbacks implemented (we have a bug) or not (we just need to go implement)

chrisglein avatar Jan 09 '20 19:01 chrisglein

I hit this issue as well. (specifically for onFocus on TextInput). Debugging I'm not able to figure out where the bug is. The event makes it from native to JS, and makes it to getListener in ReactNativeRenderer-dev.js, but onFocus in the props is always undefined. In TextInput.windows.js I was able to see the onFocus prop getting set, I wasn't able to see why it's undefined when the props are retrieved later.

Hopefully this info helps a little :)

stecrain avatar Jan 09 '20 19:01 stecrain

@chrisglein @licanhua Can you provide an update on this issue? Were you able to determine whether the callbacks were implemented or not?

jagorrin avatar Jan 27 '20 22:01 jagorrin

@kaiguo Follow up with @licanhua about the state of this and see what action we need to take.

chrisglein avatar Jan 28 '20 00:01 chrisglein

@kaiguo Can you provide a status update on this issue?

jagorrin avatar Feb 05 '20 23:02 jagorrin

@kaiguo Kai Guo FTE Can you provide a status update on this issue?

This is the next item on my list, I'll start on this pretty soon hopefully : )

kaiguo avatar Feb 05 '20 23:02 kaiguo

It's possible related the merge of .60. I just debugged with kai and the onFocus event is already sent from native to JS side. Still don't know why it's dropped finally

licanhua avatar Feb 06 '20 22:02 licanhua

Should be fixed by the PR above.

kaiguo avatar Feb 11 '20 23:02 kaiguo