Skip to content

fix(editor): support Cmd key for editor shortcuts on macOS - #8720

Open
xhon-pelushi wants to merge 2 commits into
nextcloud:mainfrom
xhon-pelushi:fix/mac-editor-shortcuts
Open

fix(editor): support Cmd key for editor shortcuts on macOS#8720
xhon-pelushi wants to merge 2 commits into
nextcloud:mainfrom
xhon-pelushi:fix/mac-editor-shortcuts

Conversation

@xhon-pelushi

@xhon-pelushi xhon-pelushi commented Aug 12, 2026

Copy link
Copy Markdown

Summary

  • Register calendar editor shortcuts via @nextcloud/vue useHotKey so macOS uses Cmd and other platforms use Ctrl (not both).
  • Call useHotKey directly from EditFull and EditSimple setup().

Fixes #8715

Test plan

  • On macOS: open an event editor and confirm Cmd+Enter / Cmd+Delete / Cmd+D behave as expected; Escape still cancels
  • On Windows/Linux: confirm Ctrl shortcuts still work; plain Ctrl must not also fire the Cmd bindings on macOS

Comment thread src/mixins/EditorMixin.js Outdated
@odzhychko odzhychko self-assigned this Aug 12, 2026
@xhon-pelushi

Copy link
Copy Markdown
Author

Thanks for the review — pushed a follow-up that switches the editor shortcuts to useHotKey (via a small useEditorHotKeys composable used from both EditSimple and EditFull).

  • Escape / Ctrl|Cmd+Enter / Ctrl|Cmd+Delete / Ctrl|Cmd+D are registered through @nextcloud/vue/composables/useHotKey
  • On macOS that means Cmd only (not Ctrl||Meta)
  • The mixin window keydown listeners and handlers are removed

Happy to adjust further if needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The editor mixin is already a common library between both editors, why do we now need to extract and abstract this in to a composable? useHotKey is already a composable, so we are wrapping a @nextcloud composable in a local composable?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — the local wrapper is gone. EditFull / EditSimple now call @nextcloud/vue useHotKey directly from setup(); useEditorHotKeys.js was removed.

@xhon-pelushi
xhon-pelushi force-pushed the fix/mac-editor-shortcuts branch from e3ac8a5 to da86e8c Compare August 14, 2026 03:41
Register Escape / Ctrl-or-Cmd+Enter / Delete / d via @nextcloud/vue
useHotKey so macOS uses Cmd and other platforms use Ctrl (not both).

Call useHotKey directly from EditFull and EditSimple setup() instead of
wrapping it in a local composable.

Fixes nextcloud#8715

Signed-off-by: xhon-pelushi <xhon@pelushi.com>
@xhon-pelushi
xhon-pelushi force-pushed the fix/mac-editor-shortcuts branch from da86e8c to 795ed24 Compare August 14, 2026 03:41
@xhon-pelushi

Copy link
Copy Markdown
Author

Thanks @odzhychko and @SebastianKrupinski — updated to call useHotKey directly from EditFull / EditSimple setup() (no local wrapper composable). macOS gets Cmd via useHotKey; Ctrl is not also accepted for those bindings.

Comment thread src/views/EditFull.vue
Comment thread src/views/EditFull.vue
getCurrentInstance() returned null when called inside the hotkey
callbacks themselves, since they fire later on keydown, outside
Vue's active-instance context during setup(). Resolve proxy once,
synchronously, and close over it instead.

Also set allowInModal: true - useHotKey ignores keystrokes inside a
modal by default, and the event editor is rendered as one, so none
of the shortcuts fired at all.

Signed-off-by: xhon-pelushi <xhon@pelushi.com>
@xhon-pelushi
xhon-pelushi force-pushed the fix/mac-editor-shortcuts branch from 58f4089 to e98f9fb Compare August 15, 2026 20:42

@odzhychko odzhychko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xhon-pelushi #8720 (comment) is still open.

Just inline the logic into setup in EditorMixin (or is there a reason why it doesn't work?). Also no need for the new code comments.

@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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 is used instead of Cmd in editor shortcuts under MacOS

3 participants