feat: enhance keybinding import validation and improve error handling

This commit is contained in:
Anwarul Islam
2025-07-18 08:30:42 +06:00
parent 8e4661951d
commit c3caefc001
3 changed files with 31 additions and 12 deletions
+11 -11
View File
@@ -233,19 +233,19 @@ export function useActionHandler<A extends Action>(
// Handle ref-based isActive changes
useEffect(() => {
if (isActive && typeof isActive === "object" && "current" in isActive) {
const checkActive = () => {
// Poll for ref changes
const interval = setInterval(() => {
const shouldBind = isActive.current;
if (shouldBind && !isBound) {
bindAction(action, stableHandler);
setIsBound(true);
} else if (!shouldBind && isBound) {
unbindAction(action, stableHandler);
setIsBound(false);
if (shouldBind !== isBound) {
if (shouldBind) {
bindAction(action, stableHandler);
} else {
unbindAction(action, stableHandler);
}
setIsBound(shouldBind);
}
};
// Initial check
checkActive();
}, 100);
return () => clearInterval(interval);
}
}, [action, stableHandler, isActive, isBound]);
}