Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutocompleteInput pop-up after choice is selected #2428

Closed
Ken-Lim opened this issue Oct 13, 2018 · 17 comments
Closed

AutocompleteInput pop-up after choice is selected #2428

Ken-Lim opened this issue Oct 13, 2018 · 17 comments
Labels

Comments

@Ken-Lim
Copy link

Ken-Lim commented Oct 13, 2018

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 Ken-Lim changed the title AutocompleteInput pop-up after after choice is selected AutocompleteInput pop-up after choice is selected Oct 13, 2018
@fzaninotto fzaninotto added the bug label Oct 13, 2018
@fzaninotto
Copy link
Member

Confirmed. Weird bug.

oksuz added a commit to oksuz/react-admin that referenced this issue Oct 16, 2018
fzaninotto added a commit that referenced this issue Oct 17, 2018
@Oupsla
Copy link
Contributor

Oupsla commented Oct 26, 2018

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 ?

@Ken-Lim
Copy link
Author

Ken-Lim commented Oct 29, 2018

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.

@FACOLOMBANI
Copy link
Contributor

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

@fzaninotto
Copy link
Member

reopening as the issue seems not fixed

@fzaninotto fzaninotto reopened this Nov 13, 2018
@Oupsla
Copy link
Contributor

Oupsla commented Nov 13, 2018

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)

mikaoelitiana pushed a commit to mikaoelitiana/react-admin that referenced this issue Nov 22, 2018
@petmongrels
Copy link

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.

@hoangtuan438
Copy link

@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

@Kmaschta Kmaschta reopened this Mar 5, 2019
@hoangtuan438
Copy link

@fzaninotto @Kmaschta

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

Thanks

@Kmaschta
Copy link
Contributor

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

@FACOLOMBANI
Copy link
Contributor

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.

@Kmaschta
Copy link
Contributor

PR are welcome :)

@FACOLOMBANI
Copy link
Contributor

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}/>`

@Kmaschta Kmaschta removed the confirmed label Apr 3, 2019
@fzan
Copy link
Contributor

fzan commented May 6, 2019

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

@Kmaschta
Copy link
Contributor

Kmaschta commented May 6, 2019

Yep, it's still open.

Related to #3031

@amayatsky
Copy link

amayatsky commented Jun 6, 2019

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);

@fzaninotto
Copy link
Member

Fixed by #3031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants