fix: made ctrl and shift state reset when switching windows to solve bulk editing issues (#8051)

* Fixed Ctrl Pressing when window is blurred

* Fixed Recent Files behavior with shift and ctrl
This commit is contained in:
Lucas Oliveira 2025-05-14 16:34:04 -03:00 committed by GitHub
commit d2f2f9074d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View file

@ -79,12 +79,23 @@ export default function RecentFilesComponent({
}
};
// Reset key states when window loses focus
const handleBlur = () => {
setIsShiftPressed(false);
};
document.addEventListener("keydown", handleKeyDown);
document.addEventListener("keyup", handleKeyUp);
window.addEventListener("blur", handleBlur);
// Clean up event listeners when component unmounts
return () => {
document.removeEventListener("keydown", handleKeyDown);
document.removeEventListener("keyup", handleKeyUp);
window.removeEventListener("blur", handleBlur);
// Reset key state on unmount
setIsShiftPressed(false);
};
}, []);

View file

@ -119,12 +119,25 @@ const HomePage = ({ type }: { type: "flows" | "components" | "mcp" }) => {
}
};
// Reset key states when window loses focus
const handleBlur = () => {
setIsShiftPressed(false);
setIsCtrlPressed(false);
};
document.addEventListener("keydown", handleKeyDown);
document.addEventListener("keyup", handleKeyUp);
window.addEventListener("blur", handleBlur);
// Clean up event listeners when component unmounts
return () => {
document.removeEventListener("keydown", handleKeyDown);
document.removeEventListener("keyup", handleKeyUp);
window.removeEventListener("blur", handleBlur);
// Reset key states on unmount
setIsShiftPressed(false);
setIsCtrlPressed(false);
};
}, []);
@ -170,6 +183,14 @@ const HomePage = ({ type }: { type: "flows" | "components" | "mcp" }) => {
);
}, [data.flows]);
// Reset key states when navigating away
useEffect(() => {
return () => {
setIsShiftPressed(false);
setIsCtrlPressed(false);
};
}, [folderId]);
return (
<CardsWrapComponent
onFileDrop={handleFileDrop}