From 6bed022896050a39d111e9023daf400e90881431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20R=C3=BCfenacht?= Date: Thu, 12 Feb 2026 12:05:34 +0100 Subject: [PATCH] fix(Filter): filters shouldn't add more body tags There is an issue with changing from one filter to another with the "filter target" dropdown. If you change a filter, the stimulus controller will add a body tag with the filter element inside it. If you repeat doing that, you will have N amount of body tags in your DOM. --- src/Resources/assets/controllers/filter_controller.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Resources/assets/controllers/filter_controller.js b/src/Resources/assets/controllers/filter_controller.js index 053200f1..696ec72a 100644 --- a/src/Resources/assets/controllers/filter_controller.js +++ b/src/Resources/assets/controllers/filter_controller.js @@ -28,7 +28,10 @@ export default class extends Controller { const parser = new DOMParser(); const template = choosenOption.getAttribute('data-value-template') const doc = parser.parseFromString(template.replace(/{name}/g, valueField.getAttribute('name')), 'text/html'); - valueField.parentNode.replaceChild(doc.body, valueField); + if(!doc.body?.childNodes?.[0]) { + throw new Error('No template found'); + } + valueField.parentNode.replaceChild(doc.body.childNodes[0], valueField); } open() {