Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Edit the previous message (ArrowUp)" shortcut inteferes with "Previous chat (Option + ArrowUp)" shortcut #6841

Open
2 tasks done
escherlies opened this issue Mar 22, 2024 · 1 comment
Labels

Comments

@escherlies
Copy link

Using a supported version?

  • I have searched searched open and closed issues for duplicates.
  • I am using Signal-Desktop as provided by the Signal team, not a 3rd-party package.

Overall summary

When attempting to navigate to a previous chat using the keyboard shortcut 'Option + ArrowUp' in Signal, the application incorrectly triggers the 'ArrowUp' shortcut functionality, which is designated for editing the last message sent. This conflict interferes with the intended navigation action.

Steps to reproduce

  1. Open the Signal application.
  2. Ensure there is at least one previous chat available above the current chat selection.
  3. Press and hold the 'Option' key and press the 'ArrowUp' key to navigate to the previous chat.

Expected result

The application should recognize the 'Option + ArrowUp' keyboard shortcut as a distinct command to navigate between chats, and it should successfully switch the focus to the previous chat in the list without invoking the edit action of the last message.

Actual result

The 'ArrowUp' shortcut's action (edit the last sent message) is triggered instead of navigating to the previous chat when 'Option + ArrowUp' is pressed. This results in the user's last message in the current chat being highlighted for editing, and no navigation between chats occurs.

Screenshots

No response

Signal version

7.3.0

Operating system

MacOS 14.4

Version of Signal on your phone

No response

Link to debug log

No response

@escherlies
Copy link
Author

Technical Details

Issue Analysis: Further investigation into the application's codebase revealed that the behavior is due to the isCtrlOrAlt function not recognizing the Option (also known as Alt on non-Mac systems) key on macOS. The current implementation of the function is as follows:

// ts/hooks/useKeyboardShortcuts.tsx:22
function isCtrlOrAlt(ev: KeyboardEvent): boolean {
  const { altKey, ctrlKey } = ev;
  const controlKey = get(window, 'platform') === 'darwin' && ctrlKey;
  const theAltKey = get(window, 'platform') !== 'darwin' && altKey;
  return controlKey || theAltKey;
}

This code checks for the ctrlKey when the platform is darwin (macOS), which does not account for the macOS convention of using the Option key for functionalities often associated with the Alt key on other platforms.

Proposed Code Modification: To address this issue, it is recommended to modify the isCtrlOrAlt function to recognize both the ctrlKey and altKey on macOS, thereby aligning with the expected behavior of the Option key by macOS users. A corrected version of the function is proposed below:

// ts/hooks/useKeyboardShortcuts.tsx:22
function isCtrlOrAlt(ev: KeyboardEvent): boolean {
  const { altKey, ctrlKey } = ev;
  // For macOS, check both ctrlKey and altKey, as users might expect the Option key to function similarly to Alt
  const isMac = get(window, 'platform') === 'darwin';
  const controlOrAltOnMac = isMac && (ctrlKey || altKey);
  const altKeyOnOthers = !isMac && altKey;

  return controlOrAltOnMac || altKeyOnOthers;
}

By implementing this change, the application should correctly recognize the Option + ArrowUp keyboard shortcut as intended for navigating between chats on macOS, without inadvertently triggering the edit functionality of the last message.

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

Successfully merging a pull request may close this issue.

2 participants