Merge pull request #1737 from Walzen665/feature/ctrl-s-saving-1736

Add Ctrl+S keyboard shortcut to save compose file
This commit is contained in:
Mauricio Siu 2025-04-26 16:09:46 -06:00 committed by GitHub
commit 6b818bbb51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,6 +79,22 @@ export const ComposeFileEditor = ({ composeId }: Props) => {
toast.error("Error updating the Compose config"); toast.error("Error updating the Compose config");
}); });
}; };
// Add keyboard shortcut for Ctrl+S/Cmd+S
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.key === 's' && !isLoading) {
e.preventDefault();
form.handleSubmit(onSubmit)();
}
};
document.addEventListener('keydown', handleKeyDown);
return () => {
document.removeEventListener('keydown', handleKeyDown);
};
}, [form, onSubmit, isLoading]);
return ( return (
<> <>
<div className="w-full flex flex-col gap-4 "> <div className="w-full flex flex-col gap-4 ">