sickdyd / react-search-autocomplete

A search box that filters the provided array of objects
https://sickdyd.github.io/react-search-autocomplete
MIT License
220 stars 84 forks source link

Search list display horizontally #19

Closed Nour281198 closed 3 years ago

Nour281198 commented 3 years ago

Hello,

First of all thank you for this wonderful component and for your responsiveness to the issues!

I am trying to use your component in my project. It seems to work perfectly but I have a problem with the results list that i don't understand : It it unfolds horizontally (on one single line) unlike in the demo, and I can't find any prop that can change this. Have I done something wrong?

I don't have any warning or error about that

sickdyd commented 3 years ago

@Nour281198 Hello!

Can you recreate your example on codesandbox?

It seems an issue related to the items you are passing to the component. Make sure the array elements have name and id. Could you paste here a sample of the array?

Nour281198 commented 3 years ago

I'm sorry I tried but I couldn't recreate my example on codesandbox :( I put the exact same components with the same styling but it works correctly on codesandbox.

There is a sample of my array :

const exampleTab = [
      {
        _id: "6060f44f8d6ab520320ae42a",
        email: "test@univ-lyon.fr",
        groupe: "Lyon1",
        membreDepuis: "3/28/2021, 11:25:24 PM",
        password:
          "$2b$10$Weq/Vh4IU4EWJMr8YIkn7uzPZArw2bsmFmp8vT3Nvs89hym31O17y",
        pseudo: "test"
      },
      {
       _id: "6061fbf9fdd72f043191bf40",
        email: "test2@univ-lyon.fr",
        groupe: "Lyon1",
        membreDepuis: "3/28/2021, 11:25:24 PM",
        password:
          "$2b$10$Weq/Vh4IU4EWJMr8YIkn7uzPZArw2bsmFmp8vT3Nvs89hym31O17y",
        pseudo: "test2"
      }
    ];

And then i do this remap that you suggested on another issue : const usersRemapped = exampleTab.map((user) => ({ id: user._id, name: user.pseudo }));

Nour281198 commented 3 years ago

Hello again!

I am closing this issue because I finally found the problem's source and could resolve it. It was not linked to your component, I apologise for the inconvenience (the problem was a display : flex CSS line that my project partner applied to all the ul DOM elements and that I wasn't aware of :) )

Thank you again for this great component and for your replies !