Skip to content

Commit 1dd09ab

Browse files
authored
Merge pull request #3762 from RSSNext/hotfix/input-element
chore(desktop): Release v0.4.7 for hotfix
2 parents eecf36c + 798da28 commit 1dd09ab

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

apps/desktop/layer/renderer/src/modules/command/hooks/use-register-hotkey.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@ import { getCommand } from "./use-command"
66
import type { BindingCommandId } from "./use-command-shortcut"
77
import { useCommandShortcut } from "./use-command-shortcut"
88

9+
export interface HotkeyOptions {
10+
forceInputElement?: true
11+
}
912
interface RegisterHotkeyOptions<T extends FollowCommandId> {
1013
shortcut: string
1114
commandId: T
1215
args?: Parameters<Extract<FollowCommand, { id: T }>["run"]>
1316
when?: boolean
17+
18+
options?: HotkeyOptions
1419
}
1520

21+
const IGNORE_INPUT_ELEMENT = [HTMLInputElement, HTMLTextAreaElement]
22+
1623
export const useCommandHotkey = <T extends FollowCommandId>({
1724
shortcut,
1825
commandId,
1926
when,
2027
args,
28+
options,
2129
}: RegisterHotkeyOptions<T>) => {
2230
useEffect(() => {
2331
if (!when) {
@@ -35,6 +43,15 @@ export const useCommandHotkey = <T extends FollowCommandId>({
3543
// Create a handler for each shortcut
3644
shortcuts.forEach((key) => {
3745
keyMap[key] = (event) => {
46+
const { target } = event
47+
if (
48+
!options?.forceInputElement &&
49+
(IGNORE_INPUT_ELEMENT.some((el) => target instanceof el) ||
50+
(target as HTMLElement).getAttribute("contenteditable") === "true")
51+
) {
52+
return
53+
}
54+
3855
event.preventDefault()
3956
event.stopPropagation()
4057

apps/desktop/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Folo",
33
"type": "module",
4-
"version": "0.4.6",
4+
"version": "0.4.7",
55
"private": true,
66
"description": "Follow everything in one place",
77
"author": "Folo Team",
@@ -28,6 +28,7 @@
2828
"dev:electron": "electron-vite dev",
2929
"dev:server": "pnpm run --filter=ssr dev",
3030
"dev:web": "cross-env WEB_BUILD=1 vite",
31+
"hotfix": "vv -c bump.hotfix.config.js",
3132
"publish": "electron-vite build && electron-forge publish",
3233
"start": "electron-vite preview",
3334
"update:main-hash": "tsx plugins/vite/generate-main-hash.ts"

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"format": "prettier --write .",
2020
"format:check": "prettier --check .",
2121
"generator:i18n-template": "tsx scripts/generate-i18n-locale.ts",
22-
"hotfix": "vv -c bump.hotfix.config.js",
2322
"icons:sync": "tsx scripts/svg-to-rn.ts && prettier --write apps/mobile/src/icons/**/*.tsx && eslint --fix apps/mobile/src/icons/**/*.tsx",
2423
"icons:update": "tsx scripts/update-icon.ts",
2524
"lint": "pnpm run lint:tsl && eslint",

0 commit comments

Comments
 (0)