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

AutocompleteInput pop-up after choice is selected

Open Ken-Lim opened this issue 8 years ago • 17 comments

What you were expecting: After choice is selected, AutocompleteInput filled the textInput with selected choice

What happened instead: After choice is selected, AutocompleteInput filled the textInput with selected choice then pop-up all the choices again

Steps to reproduce:

  1. Goto demo site, to edit an order (e.g. https://marmelab.com/react-admin-demo/#/commands/280)
  2. Enter a customer name in the Customer field
  3. Select the choice with your mouse
  4. All choices were pop-up again

Please see the attached GIF for the issue autocomplete

Ken-Lim avatar Oct 13 '18 06:10 Ken-Lim

Confirmed. Weird bug.

fzaninotto avatar Oct 13 '18 16:10 fzaninotto

Hello @Ken-Lim and @fzaninotto, I'm still experiencing this issue with an Autocomplete inside a Reference Input, with react-admin 2.4.0 and react-autosuggest ^9.4.2 in package-lock.json.

Little note : The ReferenceInput is outside a Create/Edit page so using a SimpleForm and overriding the form prop

 render() {
    const { deviceId } = this.state;

    return (
        <SimpleForm form="replace-device-form" resource="Device" save={this.handleSubmit}>
            <ReferenceInput
                label="Test issue 2428"
                source="deviceId"
                reference="Device"    
                onChange={(event, deviceId) => console.log(`New deviceId ${deviceId}`)}
            >
                <AutocompleteInput optionText="identification" />
            </ReferenceInput>
        </SimpleForm>
    )
}

Any idea ? Upgrading to 9.4.2 has fixed the issue for you ?

Oupsla avatar Oct 26 '18 08:10 Oupsla

Hello @Ken-Lim and @fzaninotto, I'm still experiencing this issue with an Autocomplete inside a Reference Input, with react-admin 2.4.0 and react-autosuggest ^9.4.2 in package-lock.json.

Little note : The ReferenceInput is outside a Create/Edit page so using a SimpleForm and overriding the form prop

 render() {
    const { deviceId } = this.state;

    return (
        <SimpleForm form="replace-device-form" resource="Device" save={this.handleSubmit}>
            <ReferenceInput
                label="Test issue 2428"
                source="deviceId"
                reference="Device"    
                onChange={(event, deviceId) => console.log(`New deviceId ${deviceId}`)}
            >
                <AutocompleteInput optionText="identification" />
            </ReferenceInput>
        </SimpleForm>
    )
}

Any idea ? Upgrading to 9.4.2 has fixed the issue for you ?

I upgraded to react-admin 2.4.0, which uses the react-autosuggest 9.4.2. Unfortunately, the issue is not resolve for me.

Ken-Lim avatar Oct 29 '18 15:10 Ken-Lim

i fixed this issue by adding focusInputOnSuggestionClick={false} props to the AutoSuggest component.

FACOLOMBANI avatar Nov 06 '18 11:11 FACOLOMBANI

reopening as the issue seems not fixed

fzaninotto avatar Nov 13 '18 08:11 fzaninotto

Forwarding message for example of the issue

Here : https://codesandbox.io/s/lrro0q4wnm

Go to the custom page, then write something (like omnis) in the autocomplete input and then select something (and the selection container will open again)

Oupsla avatar Nov 13 '18 08:11 Oupsla

This issue is not fixed. I can see my dependency to be "react-autosuggest": "^9.4.2", but the issue persists.

Steps to reproduce: Please find the GIF that explains the issue here: http://g.recordit.co/ng8QhldeJB.gif

Related code: My code is like the following:

<ReferenceInput label="Districts" source="districtId" reference="district" validate={[required("Mandatory")]} perPage={20}>
        <AutocompleteInput source="district" optionText="name"/>}
</ReferenceInput>

Other information:

Environment

  • React-admin version: "react": "^16.6.3", "react-admin": "^2.5.1", "react-dom": "^16.6.3"
  • Browser: Chrome
  • Stack trace (in case of a JS error): No Error On Console.

petmongrels avatar Dec 12 '18 10:12 petmongrels

@fzaninotto
I see it too on demo site https://marmelab.com/react-admin-demo/#/commands/312 the issue isn't fixed. The popup suggestion is still show again after clicking. Here's my video: https://drive.google.com/file/d/1TGRL5r0R-2-18VoYuErq_7QVsB-nbjRx/view

hoangtuan438 avatar Mar 05 '19 10:03 hoangtuan438

@fzaninotto @Kmaschta

Is there anything new on the ticket? the issue was resolved?

Thanks

hoangtuan438 avatar Mar 11 '19 03:03 hoangtuan438

Reopening this issue since it's not fixed as of the 2.8.2, we can reproduce the issue on the demo: https://marmelab.com/react-admin-demo/#/commands

Posters Galore Administration

There is also a few reports

Kmaschta avatar Mar 21 '19 17:03 Kmaschta

I forked the complete component because i needed lots of customisations in it, i solve this problem by adding focusInputOnSuggestionClick={false} prop to the Autosuggest component.

FACOLOMBANI avatar Mar 27 '19 09:03 FACOLOMBANI

PR are welcome :)

Kmaschta avatar Mar 27 '19 10:03 Kmaschta

Since version 2.5.0 you can pass props directly from the AutocompleteInput to the Autosuggest : 'Add ability to pass custom props to react-autosuggest from > (#2410) (AskseL)' So if you do the following it should work. <AutocompleteInput source="district" optionText="name" focusInputOnSuggestionClick={false}/>`

FACOLOMBANI avatar Mar 27 '19 13:03 FACOLOMBANI

Hello, this issue is still open? I have the same behaviour, the AutocompleteInput reopens after selection. :(

Confirmed is still in the demo, https://marmelab.com/react-admin-demo/#/commands?filter=%7B%22status%22%3A%22ordered%22%2C%22customer_id%22%3A798%7D&order=DESC&page=1&perPage=25&sort=date

try to search for customer and select it

fzan avatar May 06 '19 10:05 fzan

Yep, it's still open.

Related to #3031

Kmaschta avatar May 06 '19 15:05 Kmaschta

If I set focusInputOnSuggestionClick={false} on the ReferenceInput or AutocompleteInput selection just stops working. I've made a sort of a fix for that with redux form normalize but I don't know if this is good by any means.

import React, { useRef } from "react";
import { ReferenceInput } from "react-admin";

export const normalize = Input => props => {
  const previousGoodValue = useRef(undefined);

  return (
    <Input
      {...props}
      focusInputOnSuggestionClick={false}
      normalize={(value, prevValue) => {
        if (
          value !== prevValue &&
          (previousGoodValue.current === undefined ||
            previousGoodValue.current === null)
        ) {
          previousGoodValue.current = value;
          return value;
        }
        if (value !== prevValue && prevValue === previousGoodValue.current) {
          previousGoodValue.current = value;
          return value;
        }
        return previousGoodValue.current;
      }}
    />
  );
};

export default normalize(ReferenceInput);

amayatsky avatar Jun 06 '19 07:06 amayatsky

Fixed by #3031

fzaninotto avatar Sep 02 '19 08:09 fzaninotto