Issue #2476Opened December 27, 2019by obrazkow0 reactions

How remove color picker element from DOM tree

Question

When dynamically add sectors with property type of color and following remove it(sector), color picker element not remove from DOM tree. How can i detach it, i worry about memory leaks if i will delete it manually.

I mean element

<div class="sp-container sp-hidden sp-light sp-input-disabled sp-alpha-enabled sp-palette-buttons-disabled sp-initial-disabled gjs-one-bg gjs-two-color">
    <div class="sp-palette-container">...</div>
    <div class="sp-picker-container">...</div>
</div>

After initialize multiple time property with type color i have in dom tree

<div class="sp-container sp-hidden sp-light sp-input-disabled sp-alpha-enabled sp-palette-buttons-disabled sp-initial-disabled gjs-one-bg gjs-two-color"></div>
<div class="sp-container sp-hidden sp-light sp-input-disabled sp-alpha-enabled sp-palette-buttons-disabled sp-initial-disabled gjs-one-bg gjs-two-color"></div>
<div class="sp-container sp-hidden sp-light sp-input-disabled sp-alpha-enabled sp-palette-buttons-disabled sp-initial-disabled gjs-one-bg gjs-two-color"></div>
<div class="sp-container sp-hidden sp-light sp-input-disabled sp-alpha-enabled sp-palette-buttons-disabled sp-initial-disabled gjs-one-bg gjs-two-color"></div>

Or maybe exists another way to use dynamically sectors ?

export const removeSector = (styleManager, sectorId) => {
    styleManager
        .getSector(sectorId)
        .get('properties')
        .models
        .forEach(property => styleManager.removeProperty(sectorId, property.id));

    styleManager.removeSector(sectorId);
};

import {removeSector} from "path/to/function";

export default (styleManager) => {
    return {
        addSector: () => {
            styleManager
                .addSector('border',{
                    name: 'Button Border',
                    open: true,
                    properties: [
                        {
                            name: 'Weight',
                            property: 'border-width',
                            type: 'integer',
                            units: [],
                            unit: 'px',
                            min: 0,
                            default: 0,
                        },
                        {
                            name: 'Radius',
                            property: 'border-radius',
                            type: 'integer',
                            units: [],
                            unit: 'px',
                            min: 0,
                            default: 0,
                        },
                        {
                            name: 'Color',
                            property: 'border-color',
                            type: 'color',
                        }
                    ]
                })
                .off('change:open')
        },
        removeSector: () => {
            removeSector(styleManager, 'border');
        }
    }
}


Answers (1)

artfJanuary 2, 20200 reactions

At the moment I don't see any other way to remove it if not manually

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.