Skip to content

fix: shortcuts#13003

Open
hamza221 wants to merge 1 commit into
mainfrom
fix/shortcuts
Open

fix: shortcuts#13003
hamza221 wants to merge 1 commit into
mainfrom
fix/shortcuts

Conversation

@hamza221

@hamza221 hamza221 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

fix #12976

  • ⌫ is backspace on macos
  • Fixed broken unseen/seen toggle
  • handle multiple mailboxes on next/prev
  • re-enabled search focus

Needs testing on linux and/or windows to avoid regressions

Summary by CodeRabbit

  • New Features

    • Backspace key now triggers deletion alongside the Delete key.
    • Cmd+F/Meta+F keyboard shortcut now focuses the search input for improved search workflow.
  • Improvements

    • Refined keyboard navigation to prevent unnecessary routing when selection cannot advance to a different message.
    • Enhanced robustness of seen/unseen toggle with added validation checks.

Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
@hamza221

hamza221 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

/backport to stable5.9

@ChristophWurst

Copy link
Copy Markdown
Member

Did you main have #12982 when you tested? Just to avoid any fixes for already fixed bugs.

@hamza221

hamza221 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

@coderabitAi review

@ChristophWurst

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refines keyboard shortcut handling across the Mail app's mailbox components. In Mailbox.vue, envelope navigation, deletion, and seen-toggle shortcuts gain safety guards to prevent invalid transitions. MailboxThread.vue adds a global Cmd+F shortcut handler to focus the search input, while SearchMessages.vue exposes a programmatic focus method. These changes address macOS shortcut reliability.

Changes

Keyboard Shortcut Handling

Layer / File(s) Summary
Mailbox envelope shortcut guards and deletion
src/components/Mailbox.vue
Next/prev navigation now ignores the shortcut when the next envelope would be the current one or missing. Backspace is added as a delete trigger via switch fallthrough. Seen-toggle shortcut exits early if the envelope has no flags.
Search focus shortcut and programmatic input control
src/components/MailboxThread.vue, src/components/SearchMessages.vue
MailboxThread registers a document-level keydown listener (capture phase) that intercepts Cmd+F, prevents browser default find, and focuses the search input via SearchMessages ref. SearchMessages exposes focusInput() method by assigning a ref to the search input element. Backspace shortcut mapping is added to the shortkeys configuration.

Sequence Diagram

sequenceDiagram
  participant User
  participant Document
  participant MailboxThread
  participant SearchMessages
  participant SearchInput
  User->>Document: Press Cmd+F
  Document->>MailboxThread: keydown (capture phase)
  MailboxThread->>MailboxThread: handleSearchShortcut() checks isFromFormElement
  alt Not from form element
    MailboxThread->>MailboxThread: preventDefault()
    MailboxThread->>SearchMessages: focusInput() via ref
    SearchMessages->>SearchInput: focus() via $refs.searchInput
    SearchInput->>User: Input ready for search
  else From form element
    MailboxThread->>Document: Pass through (no intercept)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • kesselb
  • GretaD

Poem

🐰 Shortcuts dance on macOS keys,
Backspace deletes with graceful ease,
Cmd+F finds what you seek,
Refs and guards make workflows sleek!
A rabbit's fix, both swift and neat. 🌙

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: shortcuts' directly reflects the main objective—fixing keyboard shortcut issues described in issue #12976, but lacks specificity about which shortcuts or platforms.
Linked Issues check ✅ Passed The PR addresses the core requirement from #12976 by restoring backspace functionality on macOS, fixing unseen/seen toggle, improving next/previous navigation, and re-enabling search focus.
Out of Scope Changes check ✅ Passed All changes directly support the shortcut fixes in scope: Mailbox.vue handles keyboard shortcuts and navigation, MailboxThread.vue manages search shortcuts, and SearchMessages.vue enables programmatic focus.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/shortcuts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/Mailbox.vue (1)

409-415: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Backspace deletion still misses the next-message navigation path.

This newly restored path still calls onDelete(env.databaseId), but onDelete later compares that numeric id with this.$route.params.threadId using strict inequality. In this same component the route param is parsed as a string first (Line 367), so deleting the currently open message via backspace/del takes the “other message open” branch and never advances to the adjacent message.

Suggested fix
-			if (id !== this.$route.params.threadId) {
+			if (id !== parseInt(this.$route.params.threadId, 10)) {
 				logger.debug('other message open, not jumping to the next/previous message')
 				return
 			}

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a9cc384e-b4a0-4eb8-bb65-71caf2999a94

📥 Commits

Reviewing files that changed from the base of the PR and between e77bff6 and bbd827e.

📒 Files selected for processing (3)
  • src/components/Mailbox.vue
  • src/components/MailboxThread.vue
  • src/components/SearchMessages.vue

Comment on lines +514 to +522
handleSearchShortcut(event) {
if (event.target.matches('input, textarea, [contenteditable]')) {
return
}
if (event.key === 'f' && event.metaKey) {
event.preventDefault()
this.$refs.searchMessages?.focusInput()
}
},

@coderabbitai coderabbitai Bot Jun 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

On Windows and Linux browsers, is Ctrl+F the keyboard shortcut for the find dialog while Cmd+F is used on macOS?

💡 Result:

Yes, that is correct. Across web browsers on Windows and Linux, Ctrl+F is the standard keyboard shortcut to open the find-in-page dialog [1][2]. On macOS, the standard shortcut for this function is Cmd+F [3][2][4]. This difference aligns with the standard modifier key conventions for each operating system: Windows and Linux applications typically use the Control (Ctrl) key for most keyboard shortcuts, while macOS applications typically use the Command (Cmd/⌘) key [3][1]. Most major web browsers—including Chrome, Firefox, Edge, and Safari—adhere to these platform-specific conventions to provide a consistent user experience [1][2][5].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="src/components/MailboxThread.vue"

echo "== Context around handleSearchShortcut =="
rg -n "handleSearchShortcut" "$file" || true
nl -ba "$file" | sed -n '480,560p'

echo
echo "== Search for focusInput usage in this component =="
rg -n "\\$refs\\.searchMessages\\?\\.focusInput\\(|focusInput\\(" "$file" || true

echo
echo "== Search repo for other keyboard shortcut handlers =="
rg -n "handleSearchShortcut|searchShortcut|key === 'f'|metaKey.*f|ctrlKey.*f" src/components src || true

Repository: nextcloud/mail

Length of output: 352


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="src/components/MailboxThread.vue"

echo "== Context around handleSearchShortcut =="
rg -n "handleSearchShortcut" "$file" || true
echo
echo "== Lines 500-540 (for the exact key handler body) =="
cat -n "$file" | sed -n '500,540p'

echo
echo "== Search for focusInput usage in this component =="
rg -n "\\$refs\\.searchMessages\\?\\.focusInput\\(|focusInput\\(" "$file" || true

echo
echo "== Search repo for other keyboard shortcut handlers (metaKey/ctrlKey + f/search) =="
rg -n "handleSearchShortcut|searchShortcut|key === 'f'|metaKey.*f|ctrlKey.*f" src || true

Repository: nextcloud/mail

Length of output: 1660


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="src/components/MailboxThread.vue"

echo "== focusInput usage in MailboxThread.vue (no $refs expansion) =="
rg -n 'focusInput\(' "$file" || true
echo
echo "== Any other keydown/shortcut handling in MailboxThread.vue around this feature =="
rg -n "keydown|key ===|metaKey|ctrlKey|handleSearchShortcut|searchMessages" "$file" || true

echo
echo "== Repo-wide: any other Ctrl/Cmd+F shortcut handlers that focus search =="
rg -n "metaKey|ctrlKey|key === 'f'|key === \"f\"|handleSearchShortcut|focusInput\(" src/components src || true

Repository: nextcloud/mail

Length of output: 100


🏁 Script executed:

#!/bin/bash
set -euo pipefail
set +u  # avoid failures from any accidental $var expansions in patterns

file="src/components/MailboxThread.vue"

echo "== focusInput usage in MailboxThread.vue =="
rg -n 'focusInput\(' "$file" || true

echo
echo "== Any keydown/shortcut handling in MailboxThread.vue around this feature =="
rg -n 'keydown|handleSearchShortcut|searchMessages|metaKey|ctrlKey|key\s*===\s*[\'"]f[\'"]' "$file" || true

echo
echo "== Repo-wide: other Ctrl/Cmd+F handlers that focus searchMessages/focusInput =="
rg -n 'focusInput\(|handleSearchShortcut|searchMessages|metaKey|ctrlKey|key\s*===\s*[\'"]f[\'"]' src || true

Repository: nextcloud/mail

Length of output: 316


🏁 Script executed:

#!/bin/bash
set -euo pipefail
set +u

file="src/components/MailboxThread.vue"

echo "== focusInput usage in MailboxThread.vue =="
rg -n "focusInput\(" "$file" || true

echo
echo "== searchMessages ref usage in MailboxThread.vue =="
rg -n "searchMessages" "$file" || true

echo
echo "== metaKey usage in MailboxThread.vue =="
rg -n "metaKey" "$file" || true

echo
echo "== ctrlKey usage in MailboxThread.vue =="
rg -n "ctrlKey" "$file" || true

echo
echo "== key check for f in MailboxThread.vue =="
rg -n "key\s*===\s*['\"]f['\"]" "$file" || true

echo
echo "== Repo-wide: any other metaKey/ctrlKey + key f shortcut handlers =="
rg -n "metaKey|ctrlKey" src || true

Repository: nextcloud/mail

Length of output: 967


Handle Ctrl+F as well as Cmd+F so message search focus works on Windows/Linux

src/components/MailboxThread.vue focuses this.$refs.searchMessages?.focusInput() only when event.key === 'f' && event.metaKey, so Ctrl+F on Windows/Linux will fall back to the browser’s native find dialog instead of focusing the mail search.

🔧 Handle both modifier keys
 		handleSearchShortcut(event) {
 			if (event.target.matches('input, textarea, [contenteditable]')) {
 				return
 			}
-			if (event.key === 'f' && event.metaKey) {
+			if (event.key === 'f' && (event.metaKey || event.ctrlKey)) {
 				event.preventDefault()
 				this.$refs.searchMessages?.focusInput()
 			}
 		},
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
handleSearchShortcut(event) {
if (event.target.matches('input, textarea, [contenteditable]')) {
return
}
if (event.key === 'f' && event.metaKey) {
event.preventDefault()
this.$refs.searchMessages?.focusInput()
}
},
handleSearchShortcut(event) {
if (event.target.matches('input, textarea, [contenteditable]')) {
return
}
if (event.key === 'f' && (event.metaKey || event.ctrlKey)) {
event.preventDefault()
this.$refs.searchMessages?.focusInput()
}
},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can someone using linux or windows tell me if this is needed

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@hamza221, from a purely technical standpoint, the behavior on Windows/Linux is predictable without needing a test:

  • event.metaKey is the Command (⌘) key on macOS only. On Windows/Linux it is always false when Ctrl is pressed.
  • So as the code stands today, pressing Ctrl+F on Windows/Linux will skip the if block entirely and the browser's native find-in-page dialog will open instead of focusing the mail search input.

Whether that is a problem depends on the intended UX:

  • If the goal is for Ctrl+F / Cmd+F to focus the mail's own search bar (consistent across all platforms), then adding || event.ctrlKey is needed.
  • If Ctrl+F on Windows/Linux is intentionally left to the browser (and only macOS gets the override), then the current code is fine as-is.

Since the PR already mentions that Cmd+F was broken on macOS and the intent seems to be restoring search-focus parity, it's likely || event.ctrlKey would be needed for Windows/Linux too — but that's a product decision you or the maintainers can confirm.

@GretaD

GretaD commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

I tested it on linux and these 2 dont work, backspace doesnt delete the msg, and the cmd f doesnt focus on search field.

  1. Backspace key now triggers deletion alongside the Delete key.
  2. Cmd+F/Meta+F keyboard shortcut now focuses the search input for improved search workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shortcuts not working on Macos

3 participants