Skip to content

Bootstrap select picker is not correctly removed / disposed during Template descruction #380

Open
@jankapunkt

Description

@jankapunkt

original finding by @lynchem

So I tried to dig into the issue we were having a little more. I believe the problem stems from a jquery control modifying the DOM. Our template is one we use for filters in a number of places. The reason we noticed the issue here is because on this particular page you can toggle from two sets of pre-defined values so it destroys and recreates the template. The template looks like this

<template name="multipleSelectFilter">
    <select id="{{queryParamKey}}-select" class="form-control selectpicker show-tick" multiple="multiple"
        data-actions-box="true" data-selected-text-format="count > 3">
        {{#each options}}
            <option value={{value}}>{{label}}</option>
        {{/each}}
    </select>
</template>

In our onRendered we do $(this.jquerySelector).selectpicker(); to initialise the control. So in the DOM instead of just our select I now have.

<div> //new parent added by the control
    <select></select> //our initial select 
    <button></button> //added by the control
</div>

In our onDestroyed we call $(this.jquerySelector).selectpicker("destroy"); but it doesn't clean up any of the new elements it created and leaves the button & enclosing div. I removed the onDestroyed callback entirely incase it was somehow preventing the default destruction from happening and it also only destroys the initial select that was part of our template. So every time I switch views on this page I end up with the old <div><button></button></div> lying around.

Has something changed with how we track what we need to remove? I'm not sure if the previous behaviour was simply to nuke everything and now we're trying to track what we should delete?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions