Skip to content

fix(Filter): filters shouldn't add more body tags#60

Merged
rugbymauri merged 1 commit into1.0-devfrom
fix/filter-controller-should-not-add-body-tags
Feb 12, 2026
Merged

fix(Filter): filters shouldn't add more body tags#60
rugbymauri merged 1 commit into1.0-devfrom
fix/filter-controller-should-not-add-body-tags

Conversation

@Ruesa18
Copy link
Contributor

@Ruesa18 Ruesa18 commented Feb 12, 2026

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.

image

@Ruesa18 Ruesa18 requested a review from renestalder February 12, 2026 11:07
@Ruesa18 Ruesa18 added the bug label Feb 12, 2026
@Ruesa18 Ruesa18 force-pushed the fix/filter-controller-should-not-add-body-tags branch from 7704dde to ce05cf0 Compare February 12, 2026 13:13
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] === undefined) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Null/undefined check.

if(!doc.body.childNodes?.[0])

Copy link
Contributor Author

@Ruesa18 Ruesa18 Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@renestalder I adapted your example. I think the body can also be null. Because of that I also just now added another question mark there - just to be sure 🙂

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.
@Ruesa18 Ruesa18 force-pushed the fix/filter-controller-should-not-add-body-tags branch from ce05cf0 to 6bed022 Compare February 12, 2026 13:47
@rugbymauri rugbymauri merged commit e3905c5 into 1.0-dev Feb 12, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants