When a TextInput is inside a Portal, cursor jumps around on edit
See original GitHub issueHere is a code sandbox demonstrating the issue
Position your cursor at the first character of the TextInput and type a several times
Note that while the first appeared at the correct location, afterwards the cursor jumps to the end and you end up with something like afooaa. My guess is that the input is (incorrectly) re-mounting.
I’m using this very simple component
import React, { useState } from "react";
import { Portal, TextInput, Provider } from "react-native-paper";
export default () => {
const [data, setData] = useState(`foo`);
return (
<Provider>
<Portal>
<TextInput value={data} onChangeText={setData} />
</Portal>
</Provider>
);
};
When not inside of a Portal this works fine.
It also sometimes works fine even in a Portal, I have a team member that tried to fix this issue by modifying our code, and actually got it working from inside a Portal by introducing a ton of duplication and awkward state. I have not been able to narrow down what exactly makes it work again, but this reduced test case shows the incorrect behavior regardless.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:8

Top Related StackOverflow Question
I guess, if you move Portal outside component, somewhere to parents, it will work. Try out my workaround from here: https://github.com/jeremybarbet/react-native-portalize/issues/6#issuecomment-761907191
Using this terrible hack instead of
TextInputis terrible but seems to work