Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.expensify.chat;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.uimanager.util.ReactFindViewUtil;

class RNTextInputResetModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
reactContext
) {
override fun getName(): String = "RNTextInputReset"

// Props to https://github.com/MattFoley for this temporary hack
// https://github.com/facebook/react-native/pull/12462#issuecomment-298812731
@ReactMethod
fun resetKeyboardInput(nativeId: String) {
reactContext.runOnUiQueueThread {
val imm = reactApplicationContext.baseContext.getSystemService(
Context.INPUT_METHOD_SERVICE
) as? InputMethodManager

val reactNativeView = currentActivity?.findViewById<View>(android.R.id.content)
val viewToReset = reactNativeView?.let { ReactFindViewUtil.findView(it, nativeId) }
imm?.restartInput(viewToReset)
}
}
}
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,8 @@
"pnrs",
"POLICYCHANGELOG_ADD_EMPLOYEE",
"xcshareddata",
"xcuserdata"
"xcuserdata",
"inputmethod"
],
"ignorePaths": [
"src/languages/de.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ function ComposerWithSuggestions(
if (!RNTextInputReset) {
return;
}
RNTextInputReset.resetKeyboardInput(findNodeHandle(textInputRef.current));
}, [textInputRef]);
RNTextInputReset.resetKeyboardInput(CONST.COMPOSER.NATIVE_ID);
}, []);

const debouncedSaveReportComment = useMemo(
() =>
Expand Down
2 changes: 1 addition & 1 deletion src/types/modules/react-native.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type AppStateTrackerModule = {
};

type RNTextInputResetModule = {
resetKeyboardInput: (nodeHandle: number | null) => void;
Comment thread
war-in marked this conversation as resolved.
resetKeyboardInput: (nativeId: string) => void;
};

type RNNavBarManagerModule = {
Expand Down