Skip to content

Commit

Permalink
fix(DOM): potential issue with simple layout if there is lvl0, lvl2 b…
Browse files Browse the repository at this point in the history
…ut no lvl1
  • Loading branch information
maxiloc committed Jun 21, 2016
1 parent c806c46 commit 57c0101
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/lib/DocSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class DocSearch {
]).join('<span class="aa-suggestion-title-separator"> › </span>');
let text = utils.getSnippetedValue(hit, 'content');
let isTextOrSubcatoryNonEmpty = (subcategory && subcategory != "") || (displayTitle && displayTitle != "");
let isLvl1EmptyOrDuplicate = ! subcategory || subcategory == '' || subcategory == category;
let isLvl2 = displayTitle && displayTitle != '' && displayTitle != subcategory;
let isLvl1 = !isLvl2 && (subcategory && subcategory != '' && subcategory != category);
let isLvl0 = !isLvl1 && !isLvl2;
Expand All @@ -206,6 +207,7 @@ class DocSearch {
isLvl0: isLvl0,
isLvl1: isLvl1,
isLvl2: isLvl2,
isLvl1EmptyOrDuplicate: isLvl1EmptyOrDuplicate,
isCategoryHeader: hit.isCategoryHeader,
isSubCategoryHeader: hit.isSubCategoryHeader,
isTextOrSubcatoryNonEmpty: isTextOrSubcatoryNonEmpty,
Expand Down
12 changes: 7 additions & 5 deletions src/lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ let templates = {
<div class="${suggestionPrefix}--category-header">
{{^isLvl0}}
<span class="${suggestionPrefix}--category-header-lvl0 ${suggestionPrefix}--category-header-item">{{{category}}}</span>
{{^isLvl1}}
{{^isLvl1EmptyOrDuplicate}}
<span class="${suggestionPrefix}--category-header-lvl1 ${suggestionPrefix}--category-header-item">
{{{subcategory}}}
</span>
{{/isLvl1EmptyOrDuplicate}}
{{/isLvl1}}
{{/isLvl0}}
{{^isLvl1}}
<span class="${suggestionPrefix}--category-header-lvl1 ${suggestionPrefix}--category-header-item">
{{{subcategory}}}
</span>
{{/isLvl1}}
<div class="${suggestionPrefix}--title ${suggestionPrefix}--category-header-item">
{{#isLvl2}}
Expand Down

0 comments on commit 57c0101

Please sign in to comment.