mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
composebox: Fix composebox closing on clicking links.
Previously, clicking on links with the composebox open didn't close it.7391a2983fintroduced a bug where the composebox focus logic wasn't triggered at all if drag evidence wasn't present on the target. We now do a `e.target.closest("a").length > 0` check like before and only prevent the default click behavior if dragging on the target link is detected. This allows normal link clicks to trigger the previous composebox focus trigger logic. Fixes: https://chat.zulip.org/#narrow/channel/9-issues/topic/composebox.20closes.20when.20going.20to.20recent.20conversations Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com> (cherry picked from commit7a52313f85)
This commit is contained in:
committed by
Tim Abbott
parent
9415de59e9
commit
9ff265e5f6
@@ -940,18 +940,16 @@ export function initialize(): void {
|
||||
}
|
||||
|
||||
if (compose_state.composing() && $(e.target).parents("#compose").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 (should_prevent_click_behavior) {
|
||||
// To avoid the click behavior if a link is selected.
|
||||
const is_click_within_link = $(e.target).closest("a").length > 0;
|
||||
if (is_click_within_link || $(e.target).closest(".copy_codeblock").length > 0) {
|
||||
const is_selecting_link_text = is_click_within_link && mouse_drag.is_drag(e);
|
||||
if (is_selecting_link_text) {
|
||||
// Avoid triggering the click handler for a link
|
||||
// when just dragging over it to select the text.
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// Refocus compose message text box if one clicks an external
|
||||
// link/url to view something else while composing a message.
|
||||
// See issue #4331 for more details.
|
||||
|
||||
Reference in New Issue
Block a user