Skip to content

Commit 3903dfe

Browse files
committed
adjust standalone native module
1 parent f6d13e3 commit 3903dfe

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

android/app/src/main/java/com/expensify/chat/RNTextInputResetModule.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.facebook.react.bridge.ReactApplicationContext;
44
import com.facebook.react.bridge.ReactContextBaseJavaModule;
55
import com.facebook.react.bridge.ReactMethod;
6+
import com.facebook.react.uimanager.util.ReactFindViewUtil;
7+
68
import android.content.Context;
79
import android.view.View;
810
import android.view.inputmethod.InputMethodManager;
@@ -24,15 +26,15 @@ public String getName() {
2426
// Props to https://github.com/MattFoley for this temporary hack
2527
// https://github.com/facebook/react-native/pull/12462#issuecomment-298812731
2628
@ReactMethod
27-
public void resetKeyboardInput(final int reactTagToReset) {
28-
reactContext.runOnUiQueueThread(new Runnable() {
29-
@Override
30-
public void run() {
31-
InputMethodManager imm = (InputMethodManager) getReactApplicationContext().getBaseContext().getSystemService(Context.INPUT_METHOD_SERVICE);
32-
if (imm != null) {
33-
View viewToReset = reactContext.getFabricUIManager().resolveView(reactTagToReset);
34-
imm.restartInput(viewToReset);
35-
}
29+
public void resetKeyboardInput(final String nativeId) {
30+
reactContext.runOnUiQueueThread(() -> {
31+
InputMethodManager imm = (InputMethodManager) getReactApplicationContext().getBaseContext().getSystemService(Context.INPUT_METHOD_SERVICE);
32+
33+
View reactNativeView = getCurrentActivity().findViewById(android.R.id.content);
34+
View viewToReset = ReactFindViewUtil.findView(reactNativeView, nativeId);
35+
36+
if (imm != null && viewToReset != null) {
37+
imm.restartInput(viewToReset);
3638
}
3739
});
3840
}

0 commit comments

Comments
 (0)