click_handlers: Don't handle clicks with meta / ctrl keypress.

Fixes #17935

This allows users to ctrl + click a link to open it in new tab
without changing the state in the current tab.
This commit is contained in:
Aman Agrawal 2024-04-05 02:33:49 +00:00 committed by Tim Abbott
parent 64cabae46d
commit 4812c81968
3 changed files with 28 additions and 0 deletions

View File

@ -483,6 +483,10 @@ export function initialize() {
// SIDEBARS
$(".buddy-list-section").on("click", ".selectable_sidebar_block", (e) => {
if (e.metaKey || e.ctrlKey) {
return;
}
const $li = $(e.target).parents("li");
activity_ui.narrow_for_user({$li});
@ -841,6 +845,10 @@ export function initialize() {
});
$("body").on("click", "#header-container .brand", (e) => {
if (e.metaKey || e.ctrlKey) {
return;
}
e.preventDefault();
e.stopPropagation();

View File

@ -1270,6 +1270,10 @@ export function initialize() {
);
$("body").on("keydown", ".inbox-header", (e) => {
if (e.metaKey || e.ctrlKey) {
return;
}
if (keydown_util.is_enter_event(e)) {
e.preventDefault();
e.stopPropagation();
@ -1289,6 +1293,10 @@ export function initialize() {
});
$("body").on("keydown", ".inbox-row", (e) => {
if (e.metaKey || e.ctrlKey) {
return;
}
if (keydown_util.is_enter_event(e)) {
e.preventDefault();
e.stopPropagation();
@ -1299,6 +1307,10 @@ export function initialize() {
});
$("body").on("click", "#inbox-list .inbox-left-part-wrapper", (e) => {
if (e.metaKey || e.ctrlKey) {
return;
}
const $elt = $(e.currentTarget);
col_focus = COLUMNS.RECIPIENT;
focus_clicked_list_element($elt);

View File

@ -1548,6 +1548,10 @@ export function initialize({
});
$("body").on("click", "td.recent_topic_stream", (e) => {
if (e.metaKey || e.ctrlKey) {
return;
}
e.stopPropagation();
const topic_row_index = $(e.target).closest("tr").index();
focus_clicked_element(topic_row_index, COLUMNS.stream);
@ -1555,6 +1559,10 @@ export function initialize({
});
$("body").on("click", "td.recent_topic_name", (e) => {
if (e.metaKey || e.ctrlKey) {
return;
}
e.stopPropagation();
// The element's parent may re-render while it is being passed to
// other functions, so, we get topic_key first.