feat(hide-columns): don't break on dom changes
This commit is contained in:
parent
10de1a7de7
commit
c5197928b1
@ -31,6 +31,8 @@ export class HideColumns {
|
|||||||
|
|
||||||
_autoHide;
|
_autoHide;
|
||||||
|
|
||||||
|
_mutationObserver;
|
||||||
|
|
||||||
headerToHider = new Map();
|
headerToHider = new Map();
|
||||||
hiderToHeader = new Map();
|
hiderToHeader = new Map();
|
||||||
|
|
||||||
@ -69,6 +71,9 @@ export class HideColumns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[...this._element.querySelectorAll('th')].filter(th => !th.hasAttribute(HIDE_COLUMNS_NO_HIDE)).forEach(th => this.setupHideButton(th));
|
[...this._element.querySelectorAll('th')].filter(th => !th.hasAttribute(HIDE_COLUMNS_NO_HIDE)).forEach(th => this.setupHideButton(th));
|
||||||
|
|
||||||
|
this._mutationObserver = new MutationObserver(this._tableMutated.bind(this));
|
||||||
|
this._mutationObserver.observe(this._element, { childList: true, subtree: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
setupHideButton(th) {
|
setupHideButton(th) {
|
||||||
@ -217,6 +222,15 @@ export class HideColumns {
|
|||||||
hider.style.top = thR.height + 'px';
|
hider.style.top = thR.height + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_tableMutated(mutationList, observer) {
|
||||||
|
console.log('_tableMutated', mutationList, observer);
|
||||||
|
|
||||||
|
if (!Array.from(mutationList).some(mutation => mutation.type === 'childList'))
|
||||||
|
return;
|
||||||
|
|
||||||
|
[...this._element.querySelectorAll('th')].filter(th => !th.hasAttribute(HIDE_COLUMNS_NO_HIDE)).forEach(th => this.updateColumnDisplay(this.colIndex(th), this.isHiddenColumn(th)));
|
||||||
|
}
|
||||||
|
|
||||||
getStorageKey(th) {
|
getStorageKey(th) {
|
||||||
// get handler name
|
// get handler name
|
||||||
const handlerIdent = document.querySelector('[uw-handler]').getAttribute('uw-handler');
|
const handlerIdent = document.querySelector('[uw-handler]').getAttribute('uw-handler');
|
||||||
|
|||||||
Reference in New Issue
Block a user