diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 6b8f0df7b..17f193cae 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -64,6 +64,7 @@ - **Reveal** - Added new `active` state that allows you to show `reveal` programatically - **Search** - Cache can now be cleared using `$('.search').search('clear cache')` - **Segment** - Added `padded` and `very padded` segment variations +- **Search** - Search now operates off a unique id generated by result position to retrieve results. For example category #1's first result is 'A1' . Previously result titles were used as their "id", which could cause issues with duplicate titles, or results that do not contain a title. - **Sidebar** - Improved animation performance through performance debugging. Sidebar now caches, width, height, rtl direction on load. - **Site** - Added in `pageOverflowX` variable, default theme hides horizontal scrollbars on `body` - **Tabs* - Added `parseScripts` option, defaults to `once` parsing inline scripts only first load @@ -124,6 +125,7 @@ - **Sidebar** - Last menu item now has a border when sidebar and menu are used together - **Search** - Fixed `onSelect` not returning the correct value when using `type: category` - **Search** - Fixed `onSelect` returning the first term that matches the beginining of the selected value not the exact value. +- **Search** - `searchFields` setting now correctly replaces default fields instead of adding the user fields to defaults - **Search** - Search API calls now use the same level debug settings as search - **Steps** - Fixes bug where `ordered steps` had smaller numbers in `IE10` - **Steps** - Fixed bug where `stackable steps` were not working correctly diff --git a/src/definitions/modules/search.js b/src/definitions/modules/search.js index 28a810e60..9e6d8ed6e 100644 --- a/src/definitions/modules/search.js +++ b/src/definitions/modules/search.js @@ -639,32 +639,39 @@ $.fn.search = function(parameters) { }, id: function(results) { module.debug('Injecting unique ids into results'); + var + // since results may be object, we must use counters + categoryIndex = 0, + resultIndex = 0 + ; if(settings.type === 'category') { // iterate through each category result - $.each(results, function(categoryIndex, category) { - if($.isArray(category.results)) { - $.each(category.results, function(resultIndex, value) { - var - result = category.results[resultIndex] - ; - if(result.id === undefined) { - result.id = module.create.id(categoryIndex, resultIndex); - } - module.inject.result(result, resultIndex, categoryIndex); - }); - } + resultIndex = 0; + $.each(results, function(index, category) { + $.each(category.results, function(index, value) { + var + result = category.results[index] + ; + if(result.id === undefined) { + result.id = module.create.id(resultIndex, categoryIndex); + } + module.inject.result(result, resultIndex, categoryIndex); + resultIndex++; + }); + categoryIndex++; }); } else { // top level - $.each(results, function(resultIndex, value) { + $.each(results, function(index, value) { var - result = results[resultIndex] + result = results[index] ; if(result.id === undefined) { result.id = module.create.id(resultIndex); } module.inject.result(result, resultIndex); + resultIndex++; }); } return results;