mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 11:52:01 +00:00
links: Fix unnecessary blocking of click behavior.
Links become unclickable if the following is true:
1. Composebox is open
2. You have selected some text
Currently doing this will prevent the default click behavior
which is a big bug and can get quite annoying.
We now switch to a more robust check which only prevents the
click behavior if some drag evidence is present, determined with
`mouse_drag.is_drag`
Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
(cherry picked from commit 7391a2983f)
This commit is contained in:
committed by
Tim Abbott
parent
9a2194ef6c
commit
e7796305d2
@@ -20,6 +20,7 @@ import * as message_edit from "./message_edit.ts";
|
|||||||
import * as message_lists from "./message_lists.ts";
|
import * as message_lists from "./message_lists.ts";
|
||||||
import * as message_store from "./message_store.ts";
|
import * as message_store from "./message_store.ts";
|
||||||
import * as message_view from "./message_view.ts";
|
import * as message_view from "./message_view.ts";
|
||||||
|
import * as mouse_drag from "./mouse_drag.ts";
|
||||||
import * as narrow_state from "./narrow_state.ts";
|
import * as narrow_state from "./narrow_state.ts";
|
||||||
import * as navigate from "./navigate.ts";
|
import * as navigate from "./navigate.ts";
|
||||||
import {page_params} from "./page_params.ts";
|
import {page_params} from "./page_params.ts";
|
||||||
@@ -939,11 +940,14 @@ export function initialize(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (compose_state.composing() && $(e.target).parents("#compose").length === 0) {
|
if (compose_state.composing() && $(e.target).parents("#compose").length === 0) {
|
||||||
const is_inside_link = $(e.target).closest("a").length > 0;
|
const should_prevent_click_behavior = mouse_drag.is_drag(e);
|
||||||
if (is_inside_link || $(e.target).closest(".copy_codeblock").length > 0) {
|
if (
|
||||||
|
should_prevent_click_behavior ||
|
||||||
|
$(e.target).closest(".copy_codeblock").length > 0
|
||||||
|
) {
|
||||||
// We want to avoid blurring a selected link by triggering a
|
// We want to avoid blurring a selected link by triggering a
|
||||||
// focus event on the compose textarea.
|
// focus event on the compose textarea.
|
||||||
if (is_inside_link && document.getSelection()?.type === "Range") {
|
if (should_prevent_click_behavior) {
|
||||||
// To avoid the click behavior if a link is selected.
|
// To avoid the click behavior if a link is selected.
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user