In some cases, Parsoid's p-wrap DOM pass expands the scope of a template to include a preceding paragraph. The following Parsoid command-line session demonstrates the problem.
[subbu@earth:~/work/wmf/parsoid] echo -e "foo\n\n{{1x|[[Category:Boo]]<div>x</div>}}" | php bin/parse.php --dump dom:pre-pwrap,dom:post-pwrap ----- DOM: pre-pwrap ----- <body data-parsoid='{"tmp":{}}'>foo <meta typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"tsr":[5,40],"src":"{{1x|[[Category:Boo]]<div>x</div>}}","tmp":{"tplarginfo":"{\"dict\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"[[Category:Boo]]<div>x</div>\"}}},\"paramInfos\":[{\"k\":\"1\",\"srcOffsets\":[10,10,10,38]}]}","tagId":2}}'/><link rel="mw:PageProp/Category" href="./Category:Boo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Boo"},"sa":{"href":"Category:Boo"},"tmp":{"inTransclusion":true,"tagId":3}}'/><div data-parsoid='{"stx":"html","tmp":{"inTransclusion":true,"tagId":4}}'>x</div><meta typeof="mw:Transclusion/End" about="#mwt1" data-parsoid='{"tsr":[null,40],"tmp":{"inTransclusion":true,"tagId":5}}'/> </body> -------------------------- ----- DOM: post-pwrap ----- <body data-parsoid='{"tmp":{}}'><p data-parsoid='{"tmp":{}}'>foo <meta typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"tsr":[5,40],"src":"{{1x|[[Category:Boo]]<div>x</div>}}","tmp":{"tplarginfo":"{\"dict\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"[[Category:Boo]]<div>x</div>\"}}},\"paramInfos\":[{\"k\":\"1\",\"srcOffsets\":[10,10,10,38]}]}","tagId":2}}'/><link rel="mw:PageProp/Category" href="./Category:Boo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Boo"},"sa":{"href":"Category:Boo"},"tmp":{"inTransclusion":true,"tagId":3}}'/></p><div data-parsoid='{"stx":"html","tmp":{"inTransclusion":true,"tagId":4}}'>x</div><meta typeof="mw:Transclusion/End" about="#mwt1" data-parsoid='{"tsr":[null,40],"tmp":{"inTransclusion":true,"tagId":5}}'/> </body> --------------------------- <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"dsr":[0,40,0,0],"firstWikitextNode":"P","pi":[[{"k":"1"}]]}' data-mw='{"parts":["foo\n\n",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"[[Category:Boo]]<div>x</div>"}},"i":0}}]}'>foo <link rel="mw:PageProp/Category" href="./Category:Boo"/></p><div about="#mwt1" data-parsoid='{"stx":"html"}'>x</div>
It is not clear why the p-wrap token pass did not already create a p-wrapper for foo there.
Original Bug Report:
The bug can be seen in the attached screenshot. In short, if the maintenance template starts with a category, selecting the template also selects the preceding paragraph. Selecting in the paragraph also selects the template just like it would be part of the template.
The issue can be reproduces with this article version and this template version.
The issue was solves with this change.