Commit Graph

20 Commits

Author SHA1 Message Date
Aman Agrawal
4a8d86f151 overlays: Add overlay to display scheduled reminders. 2025-07-02 13:02:45 -07:00
Aman Agrawal
93c4dcbdc9 hotkey: Merge uses of M hotkey.
It was not a good idea to have the hotkey
fallthrough the `case` for user not being in message list.

We merge both the cases and also remove `M` from
`message_view_only_keys`.
2025-06-20 15:56:19 -07:00
Prakhar Pratyush
b837c47ac3 hotkey: Support non-latin keyboard locales for shortcuts.
Earlier, keyboard shortcuts were not supported for non-latin
keyboard layouts.

This commit adds support for it.

Keyboard can be:
* configured to type latin text, with the QWERTY, AZERTY, etc layout.
* configured to type non-latin text.

For non-latin users, if a shortcut requires a key and it is not
present on the keyboard, they press the same physical key that a
QWERTY user would press.

Pressing QWERTY equivalent key is not a Zulip specific requirement,
non-latin users have confirmed in CZO that they use the same behaviour
on other applications.

Algorithm:
We need to determine the key combination pressed in a consistent way,
irrespective of the keyboard layout.

For keyboard layouts (e.g. QWERTY) where `event.key` results in
printable ASCII characters or named key attribute values like "Tab",
"Enter", etc., we use `event.key` directly to determine the key
combination.

For layouts where the character defined for a hotkey can't be typed
directly (e.g. 'a' in Cyrillic), users press the same physical key
combination that a QWERTY user would use (e.g. 'ф' on Cyrillic maps
to 'a' on QWERTY). In such cases, we derive the key combination
(QWERTY equivalent) using `event.code` and the `CODE_TO_QWERTY_CHAR`
map.

Here `event` is "keydown" event.

Once, the key combination is determined the action to perform is
executed.

Fixes: #19605.
2025-05-29 13:24:22 -07:00
Prakhar Pratyush
f506ccc5f4 hotkey: Fix Caps Lock incorrectly affecting Shift state in shortcuts.
Earlier, with Caps Lock enabled, pressing letters like 'a', 'i', etc
resulted in the keyboard shortcuts for 'Shift+A', 'Shift+I', etc
getting executed. Ideally, they should work only when 'Shift + Key'
is pressed.

We used to check capitalized letters, which can result either due
to `key` pressed with Caps Lock enabled or `Shift + key` pressed.

This commit fixes the bug by using the event modifiers states to
construct a fully descriptive string like 'Cmd+Ctrl+Alt+Shift+A',
and then look up that string in a single mapping for further execution.

We treat a-z letters case-insensitively. We distinguish between
'a' and 'A' as 'A' vs 'Shift+A'.

This descriptive string approach also resolves a bug where
`Ctrl + Meta + C/K/S/.` was working. We define the valid hotkey as
`Meta + C/K/S/.` for macOS and `Ctrl + C/K/S/.` for others.
2025-05-29 13:24:22 -07:00
Prakhar Pratyush
c2d0002b4f hotkey: Remove the usage of deprecated keypress event.
This commit removes the deprecated `keypress` event.

Now, we use the `keydown` event to handle all the cases.

Earlier, we used `keypress` because it allowed us to distinguish
between lowercase and uppercase characters using `event.which`.

For example:
* For 'r':
  * keypress.which = 114
  * keydown.which = 82
* For 'R':
  * keypress.which = 82
  * keydown.which = 82

As shown, `keydown.which` cannot distinguish between 'r' and 'R',
which is why `keypress` was helpful.

Now, modern browsers support `event.key` on `keydown`, which directly
gives 'r' or 'R' as needed. This makes `keypress` unnecessary, and
we can safely rely on `keydown` with `event.key` to get the exact
character.

An earlier commit in this PR #34570, in which we replaced
the `event.which` with `event.key` plays a major role as a prep
commit to help removing `keypress` event in this commit.
2025-05-29 13:24:22 -07:00
Prakhar Pratyush
ed87932c8a hotkey: Fix 'H' & 'N' being tested as unmapped keys.
Earlier, 'H' and 'N' were being tested as unmapped keys and the test
was falsely passing because these keys are handled by `process_keydown`
but the test was processing it with `process_keypress`.

This commit removes those keys from the test.

We already test them with keydown in other tests.
2025-05-29 13:24:22 -07:00
Prakhar Pratyush
e646c1bbec hotkey: Add tests for Shift + H hotkey.
Node tests for `Shift + H` hotkey was missing.
2025-05-29 13:24:22 -07:00
Prakhar Pratyush
075e398307 hotkey: Replace deprecated e.which with e.key.
The `keydown` and `keypress` event handlers defined in `hotkey.js`
were using `event.which`, which is deprecated.

This commit makes changes to use `event.key` instead.

As a side effect, it fixes a small bug where both `Alt+P` and
`Alt+Shift+P` could be used to toggle preview mode. Only `Alt+P`
is the defined shortcut for that.
2025-05-29 13:24:22 -07:00
Prakhar Pratyush
104b5c9731 hotkey: Remove a stale item in codes, in motion_keys test.
`"+": 187` was an unused item in `codes` object, in `motion_keys`
test.

This commit removes that.
2025-05-29 13:24:22 -07:00
Prakhar Pratyush
6e18aad7a6 hotkey: Fix "e shortcut works for anonymous users" test.
In f768d3330b, the node test
written was a noop because "e" hotkey is handled by `keypress`
instead of `keydown`. So, the expected codepath was never getting
executed at all.

This commit fixes the test.
2025-05-29 13:24:22 -07:00
Anders Kaseorg
d8ba3b4ea7 navbar_menus: Avoid jQuery sizzle extension :visible.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-05-18 16:22:15 -07:00
Anders Kaseorg
26f664be69 hotkey: Avoid jQuery sizzle extension :visible.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-05-18 16:22:15 -07:00
Aman Agrawal
645850ccfa hotkey: Fix warning about unused login_to_access import. 2025-04-28 16:10:49 -07:00
Ines Falcato
8d96b7879f keyboard_UI: Allow use of e hotkey for spectators.
Previously, when in anonymous login, pressing the "view original
message" button showed the original message and allowed copying it.
However, the corresponding keyboard shortcut ('e') did not work as
expected and a login pop-up appeared instead.

Now, by fixing the UI features' permissions for anonymous users, by
adding "edit_message" as a feature they can perform, they are allowed
to use the 'e' keyboard shortcut as intended.

Fixes #33838
2025-04-21 14:36:10 -07:00
Pratik Chanda
2a26f34983 hotkey: Focus visible input filter field on query streams hotkey.
Earlier, if pm_list or stream_list was zoomed in and hitting `q`
hotkey would seemingly do nothing but in the background would add
highlighted class to `stream_row` and toggle stream-list-filter.

This commit fixes this behaviour by bringing focus to currently
visible input filter field.
2025-02-05 13:23:15 -08:00
Sayam Samal
6557cd74cd stream_color: Replace spectrum color picker with native color picker.
This commit replaces the spectrum color picker used in the stream
popover and stream settings with a custom color picker popover, which
contains a grid of predefined color swatches and a custom color option.

The custom color option uses the HTML5 <input type="color"> which shows
the native browser color picker UI.

Fixes #14961.
2025-01-07 17:27:23 -08:00
Steve Howell
3895e91b23 hotkey tests: Make processing_text mocks more granular. 2025-01-07 09:43:33 -08:00
Emil Grehn
f9b95bd4f3 message_quoting: Add a "Forward message" option below "Quote message".
Forward message starts a new message with the quoted context
(message or selection).
The compose box opens with then channel picker open and no topic.

Also added documentation about this feature in the help center.

Fixes part 2 of #31953
2024-12-04 22:25:14 -08:00
Emil Grehn
8e9d581746 message_quoting: Rename 'quote_and_reply' to 'quote_message'.
To be consistent with the new naming in the app
'quote_reply' was also renamed to 'quote_message'

Fixes part of #31953
2024-12-04 22:25:14 -08:00
Anders Kaseorg
687f1b1651 tests: Rename the Node tests to *.cjs.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-11-13 09:18:56 -08:00