Fix block users select behavior

We need to have onBlur and onChange events listeners for the select for the "block user" as it advised by es-lint. But if we simply add onBlur event listener it will cause infinite loop of blur -> confirm pop-up -> cancel -> blur -> confirm pop-up... So we have to debounce the events to process them only one time.
This commit is contained in:
Andrei Alikov
2019-02-06 18:50:15 +09:00
parent 58acbecf53
commit 3e72ec379a
2 changed files with 30 additions and 6 deletions
+8
View File
@@ -0,0 +1,8 @@
export default function debounce(func, wait) {
let timeout;
return function() {
const laterCall = () => func.apply(this, arguments);
clearTimeout(timeout);
timeout = setTimeout(laterCall, wait);
};
}