Skip to content

fix: make save shortcut (Ctrl/Cmd+S) tolerate CapsLock when editing text (#9281) - #12026

Open
Godsdar wants to merge 1 commit into
excalidraw:masterfrom
Godsdar:fix/capslock-save-shortcut
Open

Godsdar wants to merge 1 commit into
excalidraw:masterfrom
Godsdar:fix/capslock-save-shortcut

Conversation

@Godsdar

@Godsdar Godsdar commented Sep 2, 2026

Copy link
Copy Markdown

Summary

actionSaveToActiveFile.keyTest was case-sensitive (event.key === KEYS.S). When CapsLock is ON, event.key is uppercase "S", so the shortcut no longer matches.

While editing a text element, the WYSIWYG editor's onkeydown (packages/excalidraw/wysiwyg/textWysiwyg.tsx) relies on actionSaveToActiveFile.keyTest to intercept Ctrl/Cmd+S and call preventDefault() + save. With CapsLock the keyTest fails, the save branch is skipped, preventDefault() is not called, and the browser default "Save Page As" fires instead of saving the .excalidraw file. This is the bug reported in #9281.

Fix

Make the keyTest case-insensitive: event.key.toLowerCase() === KEYS.S. This matches the existing actionSaveFileToDisk.keyTest (already case-insensitive with event.key.toLowerCase()).

-    event.key === KEYS.S && event[KEYS.CTRL_OR_CMD] && !event.shiftKey,
+    event.key.toLowerCase() === KEYS.S &&
+    event[KEYS.CTRL_OR_CMD] &&
+    !event.shiftKey,

Tests

Added packages/excalidraw/tests/saveShortcutTextEditing.test.tsx:

  • Ctrl/Cmd+S with CapsLock ON (event.key === "S") must save + preventDefault (reproduces the bug — fails before this fix, passes after).
  • Plain Ctrl/Cmd+S saves + preventDefault.
  • Ctrl/Cmd+Shift+S (save-as) is not hijacked by the save-to-active-file path (unchanged).
  • An unrelated Ctrl/Cmd+b key keeps the existing bail behavior (no preventDefault).
  • Escape still finalizes the editor.

Scope

  • packages/excalidraw/actions/actionExport.tsx — 1-line behavior change the keyTest.
  • packages/excalidraw/tests/saveShortcutTextEditing.test.tsx — new regression test.

Closes #9281

…ext (excalidraw#9281)

actionSaveToActiveFile.keyTest was case-sensitive (event.key === KEYS.S).
With CapsLock ON, event.key is uppercase 'S', so the WYSIWYG editor's
onkeydown skipped the save branch and never called preventDefault() —
letting the browser default 'Save Page As' fire instead of saving the
.excalidraw file.

Fix: use event.key.toLowerCase() (matches actionSaveFileToDisk.keyTest).
@vercel

vercel Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
excalidraw Ready Ready Preview Sep 2, 2026 1:02pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview – excalidraw — 8ad509ff Deployed Sep 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CTRL + S opens browser 'save as html webpage' if a text field is selected instead of saving as .excalidraw

1 participant