mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +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>
This commit is contained in:
committed by
Tim Abbott
parent
5938f685ad
commit
7391a2983f
@@ -20,6 +20,7 @@ import * as message_edit from "./message_edit.ts";
|
||||
import * as message_lists from "./message_lists.ts";
|
||||
import * as message_store from "./message_store.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 navigate from "./navigate.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) {
|
||||
const is_inside_link = $(e.target).closest("a").length > 0;
|
||||
if (is_inside_link || $(e.target).closest(".copy_codeblock").length > 0) {
|
||||
const should_prevent_click_behavior = mouse_drag.is_drag(e);
|
||||
if (
|
||||
should_prevent_click_behavior ||
|
||||
$(e.target).closest(".copy_codeblock").length > 0
|
||||
) {
|
||||
// We want to avoid blurring a selected link by triggering a
|
||||
// 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.
|
||||
e.preventDefault();
|
||||
return;
|
||||
|
Reference in New Issue
Block a user