react-native-currency-input icon indicating copy to clipboard operation
react-native-currency-input copied to clipboard

onFocus not working

Open mmfire118 opened this issue 2 years ago • 2 comments

onFocus does not work for CurrencyInput.

function test(props) {

  const [value, setValue] = React.useState(null);

  function focus() {
    console.log("FOCUSED")
  }

  function blur() {
    console.log("BLURRED")
  }


  return (
      <CurrencyInput
        value={value}
        onChangeValue={setValue}
        prefix=""
        delimiter=","
        separator="."
        precision={1}
        minValue={0}
        maxValue={100}
        suffix="%"
        onFocus={focus}
        onBlur={blur}
        {...props}
      />
  );
}

onBlur works and prints "BLURRED". "FOCUSED" is never printed. I am using onPressIn with the isFocused function to approximate onFocus, but it would be better if it just worked.

function test(props) {
  const testRef = useRef(null);

  const [value, setValue] = React.useState(null);

  function checkFocus() {
    setTimeout(function(){
      if (testRef.current.isFocused()) {
        console.log("FOCUSED")
      }
    },100);
  }

  function blur() {
    console.log("BLURRED")
  }


  return (
      <CurrencyInput
        value={value}
        onChangeValue={setValue}
        prefix=""
        delimiter=","
        separator="."
        precision={1}
        minValue={0}
        maxValue={100}
        suffix="%"
        ref={testRef}
        onPressIn={checkFocus}
        onBlur={blur}
        {...props}
      />
  );
}

mmfire118 avatar Mar 27 '22 23:03 mmfire118

Any updates?

mmfire118 avatar Apr 12 '22 18:04 mmfire118

Similar for me, onFocus works but onBlur does not

Awethentique avatar Mar 29 '24 04:03 Awethentique