Skip to content

Commit

Permalink
Telegram MainButton should react on Enter press
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed Nov 6, 2023
1 parent 426bdf3 commit 5e30f9a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/rollbar/rollbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const reportHandledError = (description: string, e: any, info?: any) => {
console.error(e);
// @ts-ignore
Rollbar.error(description, e, info)
}
Rollbar.error(description, e, info);
};
11 changes: 11 additions & 0 deletions src/lib/telegram/use-main-button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useMount } from "../react/use-mount.ts";
import WebApp from "@twa-dev/sdk";
import { useHotkeys } from "react-hotkeys-hook";

export const useMainButton = (
text: string,
Expand All @@ -23,4 +24,14 @@ export const useMainButton = (
WebApp.MainButton.hideProgress();
};
});

useHotkeys("enter", () => {
if (condition !== undefined) {
if (!condition()) {
return;
}
}

onClick();
});
};
4 changes: 2 additions & 2 deletions src/screens/deck-form/card-form-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export const CardFormView = observer((props: Props) => {
>
<h3 className={css({ textAlign: "center" })}>Add card</h3>
<Label text={"Front"}>
<Input {...cardForm.front.props} rows={7} type={"textarea"} />
<Input {...cardForm.front.props} rows={5} type={"textarea"} />
</Label>

<Label text={"Back"}>
<Input {...cardForm.back.props} rows={7} type={"textarea"} />
<Input {...cardForm.back.props} rows={5} type={"textarea"} />
</Label>
</div>
);
Expand Down

0 comments on commit 5e30f9a

Please sign in to comment.