Skip to content

When a TextInput is inside a Portal, cursor jumps around on editΒ #1668

@togakangaroo

Description

@togakangaroo

Here 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions