From 57c01014590bbfe99ebf8c06737b9905c9e8beb2 Mon Sep 17 00:00:00 2001 From: Maxime Locqueville Date: Tue, 21 Jun 2016 23:54:05 +0200 Subject: [PATCH] fix(DOM): potential issue with simple layout if there is lvl0, lvl2 but no lvl1 --- src/lib/DocSearch.js | 2 ++ src/lib/templates.js | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/DocSearch.js b/src/lib/DocSearch.js index c358f3d84..71a597669 100644 --- a/src/lib/DocSearch.js +++ b/src/lib/DocSearch.js @@ -198,6 +198,7 @@ class DocSearch { ]).join(''); 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; @@ -206,6 +207,7 @@ class DocSearch { isLvl0: isLvl0, isLvl1: isLvl1, isLvl2: isLvl2, + isLvl1EmptyOrDuplicate: isLvl1EmptyOrDuplicate, isCategoryHeader: hit.isCategoryHeader, isSubCategoryHeader: hit.isSubCategoryHeader, isTextOrSubcatoryNonEmpty: isTextOrSubcatoryNonEmpty, diff --git a/src/lib/templates.js b/src/lib/templates.js index aaab9b5c9..b96dc9335 100644 --- a/src/lib/templates.js +++ b/src/lib/templates.js @@ -36,12 +36,14 @@ let templates = {
{{^isLvl0}} {{{category}}} + {{^isLvl1}} + {{^isLvl1EmptyOrDuplicate}} + + {{{subcategory}}} + + {{/isLvl1EmptyOrDuplicate}} + {{/isLvl1}} {{/isLvl0}} - {{^isLvl1}} - - {{{subcategory}}} - - {{/isLvl1}}
{{#isLvl2}}