Clone columns in column-moved event to prevent side-effects through mutability.
Fix use of clone function. Seems like old code wasn't updated when the _clone mixin was replaced by helpers/clone.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tp/tp-table",
|
"name": "@tp/tp-table",
|
||||||
"version": "1.4.0",
|
"version": "1.4.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "tp-table.js",
|
"main": "tp-table.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@@ -10,6 +10,7 @@ import '@tp/tp-icon/tp-icon.js';
|
|||||||
import '@tp/tp-checkbox/tp-checkbox.js';
|
import '@tp/tp-checkbox/tp-checkbox.js';
|
||||||
import './tp-table-item.js';
|
import './tp-table-item.js';
|
||||||
import { DomQuery } from '@tp/helpers/dom-query.js';
|
import { DomQuery } from '@tp/helpers/dom-query.js';
|
||||||
|
import { clone } from '@tp/helpers/clone.js';
|
||||||
import { closest } from '@tp/helpers/closest.js';
|
import { closest } from '@tp/helpers/closest.js';
|
||||||
import { LitElement, html, css, svg } from 'lit';
|
import { LitElement, html, css, svg } from 'lit';
|
||||||
import ColumnResizer from './column-resizer.js';
|
import ColumnResizer from './column-resizer.js';
|
||||||
@@ -292,18 +293,18 @@ export class TpTable extends DomQuery(LitElement) {
|
|||||||
|
|
||||||
set filter(val) {
|
set filter(val) {
|
||||||
this._advFilterActive = false;
|
this._advFilterActive = false;
|
||||||
this._filter = this._clone(val);
|
this._filter = clone(val);
|
||||||
this.reloadPagedList();
|
this.reloadPagedList();
|
||||||
}
|
}
|
||||||
|
|
||||||
set statusFilter(val) {
|
set statusFilter(val) {
|
||||||
this._statusFilter = this._clone(val);
|
this._statusFilter = clone(val);
|
||||||
this.reloadPagedList();
|
this.reloadPagedList();
|
||||||
}
|
}
|
||||||
|
|
||||||
set advancedFilter(val) {
|
set advancedFilter(val) {
|
||||||
this._advFilterActive = val ? true : false;
|
this._advFilterActive = val ? true : false;
|
||||||
this._advFilters = this._clone(val);
|
this._advFilters = clone(val);
|
||||||
this.reloadPagedList();
|
this.reloadPagedList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,7 +474,7 @@ export class TpTable extends DomQuery(LitElement) {
|
|||||||
}
|
}
|
||||||
this.columns.splice(moveTo, 0, this.columns.splice(targetIdx, 1)[0])
|
this.columns.splice(moveTo, 0, this.columns.splice(targetIdx, 1)[0])
|
||||||
this.columns = [ ...this.columns ];
|
this.columns = [ ...this.columns ];
|
||||||
this.dispatchEvent(new CustomEvent('column-moved', { detail: { from: targetIdx, to: moveTo, columns: this.columns }, bubbles: true, composed: true }));
|
this.dispatchEvent(new CustomEvent('column-moved', { detail: { from: targetIdx, to: moveTo, columns: clone(this.columns) }, bubbles: true, composed: true }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user