chore(async-table): refactor
This commit is contained in:
parent
22b3780efd
commit
bfd35dbc5c
@ -184,10 +184,28 @@ export class AsyncTable {
|
||||
});
|
||||
|
||||
this._tableFilterInputs.input.forEach((input) => {
|
||||
input.submitLockObserver = new MutationObserver((mutations, observer) => {
|
||||
for (const mutation of mutations) {
|
||||
// if the submit lock has been released, trigger an update and disconnect this observer
|
||||
if (mutation.oldValue === 'true' && input.getAttribute(ATTR_SUBMIT_LOCKED) === 'false') {
|
||||
this._updateFromTableFilter(tableFilterForm);
|
||||
observer.disconnect();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const debouncedInput = debounce(() => {
|
||||
const submitLocked = input.getAttribute(ATTR_SUBMIT_LOCKED);
|
||||
if ((submitLocked === 'false' || submitLocked === null) && (input.value.length === 0 || input.value.length > 2)) {
|
||||
const submitLocked = input.getAttribute(ATTR_SUBMIT_LOCKED) === 'true';
|
||||
if (!submitLocked && (input.value.length === 0 || input.value.length > 2)) {
|
||||
this._updateFromTableFilter(tableFilterForm);
|
||||
} else if (submitLocked) {
|
||||
// observe the submit lock of the input element
|
||||
input.submitLockObserver.observe(input, {
|
||||
attributes: true,
|
||||
attributeFilter: [ATTR_SUBMIT_LOCKED],
|
||||
attributeOldValue: true,
|
||||
});
|
||||
}
|
||||
}, INPUT_DEBOUNCE);
|
||||
input.addEventListener('input', debouncedInput);
|
||||
|
||||
@ -159,11 +159,12 @@ export class Datepicker {
|
||||
// create a mutation observer that observes the datepicker instance class and sets
|
||||
// the datepicker-open DOM attribute of the input element if the datepicker has been opened
|
||||
const datepickerInstanceObserver = new MutationObserver((mutations) => {
|
||||
mutations.forEach(mutation => {
|
||||
for (const mutation of mutations) {
|
||||
if (!mutation.oldValue.includes(DATEPICKER_OPEN_CLASS) && this.datepickerInstance.dt.getAttribute('class').includes(DATEPICKER_OPEN_CLASS)) {
|
||||
this._element.setAttribute(ATTR_DATEPICKER_OPEN, true);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
datepickerInstanceObserver.observe(this.datepickerInstance.dt, {
|
||||
attributes: true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user