Skip to content

Commit

Permalink
fix(ui): blocks browser save dialog from opening when hotkey used wit…
Browse files Browse the repository at this point in the history
…h no changes (#6366)
  • Loading branch information
JessChowdhury committed May 21, 2024
1 parent f482fdc commit 0190eb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/ui/src/elements/Save/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useHotkey } from '../../hooks/useHotkey.js'
import { useEditDepth } from '../../providers/EditDepth/index.js'
import { useOperation } from '../../providers/Operation/index.js'
import { useTranslation } from '../../providers/Translation/index.js'

export const DefaultSaveButton: React.FC<{ label?: string }> = ({ label: labelProp }) => {
const { t } = useTranslation()
const { submit } = useForm()
Expand All @@ -21,7 +20,9 @@ export const DefaultSaveButton: React.FC<{ label?: string }> = ({ label: labelPr
const forceDisable = operation === 'update' && !modified

useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {
if (forceDisable) return
if (forceDisable) {
// absorb the event
}

e.preventDefault()
e.stopPropagation()
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/elements/SaveDraft/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ const DefaultSaveDraftButton: React.FC = () => {
}, [submit, collectionSlug, globalSlug, serverURL, api, locale, id, forceDisable])

useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {
if (forceDisable) return
if (forceDisable) {
// absorb the event
}

e.preventDefault()
e.stopPropagation()
Expand Down

0 comments on commit 0190eb8

Please sign in to comment.