Skip to content

Commit 0190eb8

Browse files
authored
fix(ui): blocks browser save dialog from opening when hotkey used with no changes (#6366)
1 parent f482fdc commit 0190eb8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/ui/src/elements/Save/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { useHotkey } from '../../hooks/useHotkey.js'
88
import { useEditDepth } from '../../providers/EditDepth/index.js'
99
import { useOperation } from '../../providers/Operation/index.js'
1010
import { useTranslation } from '../../providers/Translation/index.js'
11-
1211
export const DefaultSaveButton: React.FC<{ label?: string }> = ({ label: labelProp }) => {
1312
const { t } = useTranslation()
1413
const { submit } = useForm()
@@ -21,7 +20,9 @@ export const DefaultSaveButton: React.FC<{ label?: string }> = ({ label: labelPr
2120
const forceDisable = operation === 'update' && !modified
2221

2322
useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {
24-
if (forceDisable) return
23+
if (forceDisable) {
24+
// absorb the event
25+
}
2526

2627
e.preventDefault()
2728
e.stopPropagation()

packages/ui/src/elements/SaveDraft/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ const DefaultSaveDraftButton: React.FC = () => {
5757
}, [submit, collectionSlug, globalSlug, serverURL, api, locale, id, forceDisable])
5858

5959
useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {
60-
if (forceDisable) return
60+
if (forceDisable) {
61+
// absorb the event
62+
}
6163

6264
e.preventDefault()
6365
e.stopPropagation()

0 commit comments

Comments
 (0)