From 1dc4b6d17329b1435aeb663bb8461eccfe2f351a Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 21 Dec 2023 09:52:40 +0000 Subject: [PATCH] Fix for list widget with an empty paragraph as inline template Fixes #7902 --- core/modules/widgets/list.js | 7 +++++-- .../data/list-widget/WithEmptyParagraphTemplate.tid | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 editions/test/tiddlers/tests/data/list-widget/WithEmptyParagraphTemplate.tid diff --git a/core/modules/widgets/list.js b/core/modules/widgets/list.js index 78976f69a..d4ad41995 100755 --- a/core/modules/widgets/list.js +++ b/core/modules/widgets/list.js @@ -109,6 +109,7 @@ ListWidget.prototype.findExplicitTemplates = function() { this.explicitJoinTemplate = null; this.hasTemplateInBody = false; var searchChildren = function(childNodes) { + var foundInlineTemplate = false; $tw.utils.each(childNodes,function(node) { if(node.type === "list-template") { self.explicitListTemplate = node.children; @@ -118,12 +119,14 @@ ListWidget.prototype.findExplicitTemplates = function() { self.explicitJoinTemplate = node.children; } else if(node.type === "element" && node.tag === "p") { searchChildren(node.children); + foundInlineTemplate = true; } else { - self.hasTemplateInBody = true; + foundInlineTemplate = true; } }); + return foundInlineTemplate; }; - searchChildren(this.parseTreeNode.children); + this.hasTemplateInBody = searchChildren(this.parseTreeNode.children); } ListWidget.prototype.getTiddlerList = function() { diff --git a/editions/test/tiddlers/tests/data/list-widget/WithEmptyParagraphTemplate.tid b/editions/test/tiddlers/tests/data/list-widget/WithEmptyParagraphTemplate.tid new file mode 100644 index 000000000..7730f525a --- /dev/null +++ b/editions/test/tiddlers/tests/data/list-widget/WithEmptyParagraphTemplate.tid @@ -0,0 +1,13 @@ +title: ListWidget/WithEmptyParagraphTemplate +description: List widget with an empty paragraph as inline template +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + ++ +title: Output + +<$list filter="1">

++ +title: ExpectedResult + +

\ No newline at end of file