Semantic-Org / Semantic-UI

Semantic is a UI component framework based around useful principles from natural language.
http://www.semantic-ui.com
MIT License
51.12k stars 4.94k forks source link

Search Module - onSelect null 'results' #2908

Closed dekhaus closed 8 years ago

dekhaus commented 9 years ago

Hi

I have a 'mostly' working Search working.  The problem is that sometimes it does not work and I'm not sure why.  The Search is calling my search endpoint (Rails app) which is generating 'category' type json.

When I type in a string to query ('ruck') - I get back two results ...
{
  "results": {
    "Ruckus Wireless": {
      "name": "Ruckus Wireless",
      "results": [
        {
          "title": "Model: ZoneFlex 7782-E Access Point",
          "id": 1954,
          "description": "Part Number: ZF7782"
        },
        {
          "title": "Model: Zoneflex 7962 Access Point",
          "id": 1924,
          "description": "Part Number: "
        }
      ]
    }
  }
}

Specifically the 'onSelect' callback is sent two valid values for 'result' and 'response'.

I can click on either or the two result rows and everything works.

When I perform another search - say for 'headphones' - my endpoint returns the following json...

{
  "results": {
    "Bose": {
      "name": "Bose",
      "results": [
        {
          "title": "Model: SoundLink On-Ear Bluetooth Headphones",
          "id": 2205,
          "description": "Part Number: 714675-0020"
        },
        {
          "title": "Model: Soundlink Around-Ear Bluetooth Headphones",
          "id": 1589,
          "description": "Part Number: 714675-0010"
        }
      ]
    },
    "Creative": {
      "name": "Creative",
      "results": [
        {
          "title": "Model: WP-350 Wireless Bluetooth Headphones with Invisible Mic",
          "id": 1599,
          "description": "Part Number: 51EF0490AA002"
        }
      ]
    },
    "JayBird": {
      "name": "JayBird",
      "results": [
        {
          "title": "Model: Bluebuds X Sport Bluetooth Headphones - Storm White",
          "id": 2200,
          "description": "Part Number: BBX1SW"
        },
        {
          "title": "Model: Freedom Sprint Bluetooth Headphones",
          "id": 2203,
          "description": "Part Number: JF4MBL"
        }
      ]
    },
    "Motorola": {
      "name": "Motorola",
      "results": [
        {
          "title": "Model: S11-Flex HD Wireless Stereo Headphones",
          "id": 2225,
          "description": "Part Number: 89585N"
        },
        {
          "title": "Model: S11-HD Wireless Stereo Headphones",
          "id": 2231,
          "description": "Part Number: 89587N"
        }
      ]
    },
    "Parrot": {
      "name": "Parrot",
      "results": [
        {
          "title": "Model: Zik 2.0 Wireless Bluetooth Stereo Headphones",
          "id": 2387,
          "description": "Part Number: PF561000"
        },
        {
          "title": "Model: Zik 2.0 Wireless Stereo Bluetooth Headphones",
          "id": 2204,
          "description": "Part Number: PF561003"
        }
      ]
    },
    "Sennheiser": {
      "name": "Sennheiser",
      "results": [
        {
          "title": "Model: MM 450-X Wireless Bluetooth Headphones",
          "id": 2235,
          "description": "Part Number: 504513"
        },
        {
          "title": "Model: MM 500-X Wireless Bluetooth Travel Headphones",
          "id": 2206,
          "description": "Part Number: 504514"
        },
        {
          "title": "Model: MM 550-X Wireless Bluetooth Headphones",
          "id": 2244,
          "description": "Part Number: 504515"
        }
      ]
    }
  }
}

which is structurally identical to the previous result.

The problem is that the onSelect callback has null as the value for result.

Any idea what's happening and why ?

Thanks Dave

jlukic commented 9 years ago

Can you create a JSFiddle example, you can use mockResponse to specify the returned JSON and fork the link in the readme.

Also can you confirm you are using the latest version of SUI? There was bugs related to onSelect not finding the result in some cases that were solved in previous releases.

avalanche1 commented 8 years ago

Closing until there's a test case.