Skip to content

Commit

Permalink
feat: shortcuts for adding new cards with Enter & Ctrl+Enter
Browse files Browse the repository at this point in the history
Also fixed it for tauri
  • Loading branch information
sekwah41 committed Nov 23, 2023
1 parent 1e836ee commit a73fca7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
14 changes: 7 additions & 7 deletions app/renderer/src/routes/Tasks/TaskFormButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const TaskFormButton: React.FC<Props> = ({ forList, onSubmit }) => {
const [isOpen, setOpen] = useTargetOutside({ ref: formRef });

const doSubmit = useCallback(
(ref: HTMLInputElement | HTMLTextAreaElement) => {
(ref: HTMLInputElement | HTMLTextAreaElement, keepOpen = false) => {
const { value } = ref;
if (!value) return false;

Expand All @@ -37,7 +37,7 @@ const TaskFormButton: React.FC<Props> = ({ forList, onSubmit }) => {
formRef.current.reset();
}
}
setOpen(false);
if (!keepOpen) setOpen(false);

return true;
},
Expand All @@ -54,9 +54,9 @@ const TaskFormButton: React.FC<Props> = ({ forList, onSubmit }) => {
inputRef.current.focus();

inputRef.current.onkeypress = (e: KeyboardEvent) => {
if (e.keyCode === 10 && inputRef.current) {
if (e.code === "Enter" && inputRef.current) {
e.preventDefault();
doSubmit(inputRef.current);
doSubmit(inputRef.current, e.ctrlKey);
}
};
}
Expand All @@ -66,10 +66,10 @@ const TaskFormButton: React.FC<Props> = ({ forList, onSubmit }) => {
autoSize(areaRef.current);

areaRef.current.onkeypress = (e: KeyboardEvent) => {
if (e.keyCode === 10 && areaRef.current) {
if (e.code === "Enter" && areaRef.current) {
e.preventDefault();
if (
doSubmit(areaRef.current) &&
doSubmit(areaRef.current, e.ctrlKey) &&
areaRef?.current?.style?.height
)
areaRef.current.style.height = "inherit";
Expand All @@ -85,7 +85,7 @@ const TaskFormButton: React.FC<Props> = ({ forList, onSubmit }) => {
e.preventDefault();

if (forList) {
inputRef.current && doSubmit(inputRef.current);
inputRef.current && doSubmit(inputRef.current, false);
} else {
if (areaRef.current && doSubmit(areaRef.current)) {
areaRef.current.style.height = "inherit";
Expand Down
8 changes: 4 additions & 4 deletions app/tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions app/tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,9 @@
"signingIdentity": null
},
"publisher": "Roldan Montilla Jr",
"resources": [
"icons/icon.png"
],
"resources": ["icons/icon.png"],
"shortDescription": "",
"targets": [
"deb",
"appimage",
"msi",
"nsis",
"dmg",
"updater"
],
"targets": ["deb", "appimage", "msi", "nsis", "dmg", "updater"],
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
Expand Down

0 comments on commit a73fca7

Please sign in to comment.