react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Filter changes the focus of TextInput after few words and does not allow to enter long words

Open vindeolal opened this issue 7 years ago • 6 comments

Focus changes in middle of typing when filtering by text.

What you were expecting: Filter should allow user to input full text and should not change the focus of the textbox.

What happened instead: Everytime I type a text for filtering the focus of Text-box changes after entering some characters.

Steps to reproduce: Create a Filter with TextInput and use it in List

import { Filter, ReferenceInput, SelectInput, TextInput, List } from 'react-admin';
const PostFilter = (props) => (
    <Filter {...props}>
        <TextInput label="Search" source="q" resettable alwaysOn />
    </Filter>
);

export const PostList = (props) => (
    <List filters={<PostFilter />} {...props}>
        // ...
    </List>
);

In above code react-admin doesn't allow you to type a long text and changes focus of the text box after entering some characters.

Environment

  • React-admin version: 2.8.2

vindeolal avatar Apr 19 '19 07:04 vindeolal

What do you mean by "change the focus"? Does the input lose the focus?

fzaninotto avatar Apr 25 '19 16:04 fzaninotto

@fzaninotto It does not allow user to input long text and focus from TextInput changes and you need to click on the box again to input more text. Below is the GIF of same. FilterError

You can check the code in codeSandbox. If you want to check the behavior you can login to app using adminjss user and password as password.

vindeolal avatar Apr 25 '19 17:04 vindeolal

@fzaninotto While debugging we noticed that dataprovider calls server two times for every filter search.

vindeolal avatar Apr 29 '19 08:04 vindeolal

This issue has been resolved. This was an issue at a most fundamental level as described here - https://codepen.io/invisiblecomma/pen/wqLaZQ

We were redefining the functions which created our components, inside the render.

petmongrels avatar May 27 '19 14:05 petmongrels

Closing this one since it's been resolved (I haven't tested) Feel free to re-open with a way to reproduce if needed.

Kmaschta avatar Jun 12 '19 05:06 Kmaschta

I have the same issue , ListFilters Should be written out side of Main function that Solved my problem because rendering the Dataprovider calls which is out Focus my TextInput written in List Filters

npannati avatar Feb 16 '22 09:02 npannati