mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
left-sidebar: Fix clicking on stream row in left sidebar.
Clicking on the stream row should open the message view as per "Channel links in the left sidebar go to" setting. But this happens only when clicking on stream name element and not on the complete stream row, like clicking on the privacy icon or towards the left of it, opens the channel feed always irrespective of the setting. This commit fixes that. Updated the code to attach the "New topic" button handler to "#stream_filters" element instead of "body", as it was not being executed due to stopPropagation being called in the click handler for "a" element for stream row. Attaching the event to "#stream_filters" makes sure that clicking on "New topic" button calls the handler for it first and stops event from being propagated to the "a" element for stream row. Also moved "New topic" handler to stream_list.ts, as it would be easy to maintain them if all handlers for the UI are in the same file. This also fixes the bug when pressing "Enter" key after clicking on a stream row did not open the compose box for replying to the selected message which is the expected behavior when "Channel links in the left sidebar go to" setting is set to value other than "List of topics".
This commit is contained in:
@@ -13,6 +13,7 @@ import render_subscribe_to_more_streams from "../templates/subscribe_to_more_str
|
||||
|
||||
import * as blueslip from "./blueslip.ts";
|
||||
import * as browser_history from "./browser_history.ts";
|
||||
import * as compose_actions from "./compose_actions.ts";
|
||||
import type {Filter} from "./filter.ts";
|
||||
import * as hash_util from "./hash_util.ts";
|
||||
import {$t} from "./i18n.ts";
|
||||
@@ -926,7 +927,13 @@ export function set_event_handlers({
|
||||
}: {
|
||||
on_stream_click: (stream_id: number, trigger: string) => void;
|
||||
}): void {
|
||||
$("#stream_filters").on("click", "li .subscription_block .stream-name", (e) => {
|
||||
$("#stream_filters").on("click", "li .subscription_block", (e) => {
|
||||
// Left sidebar channel links have an `href` so that the
|
||||
// browser will preview the URL and you can middle-click it.
|
||||
//
|
||||
// But we want to control what the click does to follow the
|
||||
// user's default left sidebar click action, rather than
|
||||
// taking you to the channel feed.
|
||||
if (e.metaKey || e.ctrlKey || e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
@@ -1026,6 +1033,19 @@ export function set_event_handlers({
|
||||
}
|
||||
});
|
||||
|
||||
$("#stream_filters").on("click", ".channel-new-topic-button", function (this: HTMLElement, e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
const stream_id = Number.parseInt(this.dataset.streamId!, 10);
|
||||
compose_actions.start({
|
||||
message_type: "stream",
|
||||
stream_id,
|
||||
topic: "",
|
||||
trigger: "clear topic button",
|
||||
keep_composebox_empty: true,
|
||||
});
|
||||
});
|
||||
|
||||
$("#streams_header")
|
||||
.expectOne()
|
||||
.on("click", (e) => {
|
||||
|
||||
Reference in New Issue
Block a user