react-native-community/discussions-and-proposals

Add handlers for different events when you press keyboard button

IslamRustamov opened this issue · 0 comments

Introduction

In RN's TextInput we only have onChangeText prop, which is fired (for example, in Android) by ReactTextChangedEvent inside onTextChanged function of TextWatcher interface.

Details

There is a small problem with masking in "vanilla" RN, where you see that initially letter is inserted into input and only then mask applies, which causes "jumping". To solve this we might use 3rd party library or dig into native code ourselves and write patch.

Why won't we expose at least beforeTextChanged to also be invokable with some event (like ReactBeforeTextChangedEvent), so that we could workaround masking problem without 3rd party libraries?

Discussion points

  1. Why won't we expose other methods of TextWatcher interface to RN's TextInput?
  2. How could we implement proper masking without "jumping" in RN if we don't have an access to event "before" button was pressed?

P.S. I am willing to try out and implement it myself, to see whether it's actually going to solve the issue of masking and open a PR, if you are ok with that.