SQL Migration extension - accessibility bug - fixes filter enter and focus (#15953)

* fix filter enter and focus

* debounce and fix search

* refactor null check and undo change/remove await

* using control types to improve and remove 'any'
This commit is contained in:
brian-harris
2021-07-02 19:11:50 -07:00
committed by GitHub
parent 9f77c74b9f
commit 19e25f04b1
4 changed files with 59 additions and 2 deletions

View File

@@ -156,3 +156,35 @@ export function findDropDownItemIndex(dropDown: DropDownComponent, value: string
return -1;
}
export function debounce(delay: number): Function {
return decorate((fn, key) => {
const timerKey = `$debounce$${key}`;
return function (this: any, ...args: any[]) {
clearTimeout(this[timerKey]);
this[timerKey] = setTimeout(() => fn.apply(this, args), delay);
};
});
}
export function decorate(decorator: (fn: Function, key: string) => Function): Function {
return (_target: any, key: string, descriptor: any) => {
let fnKey: string | null = null;
let fn: Function | null = null;
if (typeof descriptor.value === 'function') {
fnKey = 'value';
fn = descriptor.value;
} else if (typeof descriptor.get === 'function') {
fnKey = 'get';
fn = descriptor.get;
}
if (!fn || !fnKey) {
throw new Error('not supported');
}
descriptor[fnKey] = decorator(fn, key);
};
}