mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
stream_list: Enter should use web_channel_default_view.
This previously misleadingly named on_stream_click masked the fact that this was not using the actual click handler.
This commit is contained in:
@@ -922,27 +922,19 @@ export function initialize_tippy_tooltips(): void {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function set_event_handlers({
|
function on_sidebar_channel_click(
|
||||||
show_channel_feed,
|
stream_id: number,
|
||||||
}: {
|
// Null is used when this is called via `Enter`, because the
|
||||||
show_channel_feed: (stream_id: number, trigger: string) => void;
|
// keyboard abstraction we're using doesn't need to pass on the event.
|
||||||
}): void {
|
e: JQuery.ClickEvent | null,
|
||||||
$("#stream_filters").on("click", "li .subscription_block", (e) => {
|
show_channel_feed: (stream_id: number, trigger: string) => void,
|
||||||
// Left sidebar channel links have an `href` so that the
|
): void {
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
clear_and_hide_search();
|
clear_and_hide_search();
|
||||||
|
if (e !== null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
const stream_id = stream_id_for_elt($(e.target).parents("li.narrow-filter"));
|
|
||||||
const current_narrow_stream_id = narrow_state.stream_id();
|
const current_narrow_stream_id = narrow_state.stream_id();
|
||||||
const current_topic = narrow_state.topic();
|
const current_topic = narrow_state.topic();
|
||||||
|
|
||||||
@@ -969,8 +961,7 @@ export function set_event_handlers({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
user_settings.web_channel_default_view ===
|
user_settings.web_channel_default_view === web_channel_default_view_values.channel_feed.code
|
||||||
web_channel_default_view_values.channel_feed.code
|
|
||||||
) {
|
) {
|
||||||
show_channel_feed(stream_id, "sidebar");
|
show_channel_feed(stream_id, "sidebar");
|
||||||
return;
|
return;
|
||||||
@@ -1031,6 +1022,26 @@ export function set_event_handlers({
|
|||||||
navigate_to_stream();
|
navigate_to_stream();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function set_event_handlers({
|
||||||
|
show_channel_feed,
|
||||||
|
}: {
|
||||||
|
show_channel_feed: (stream_id: number, trigger: string) => void;
|
||||||
|
}): void {
|
||||||
|
$("#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const stream_id = stream_id_for_elt($(e.target).parents("li.narrow-filter"));
|
||||||
|
on_sidebar_channel_click(stream_id, e, show_channel_feed);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#stream_filters").on("click", ".channel-new-topic-button", function (this: HTMLElement, e) {
|
$("#stream_filters").on("click", ".channel-new-topic-button", function (this: HTMLElement, e) {
|
||||||
@@ -1095,8 +1106,7 @@ export function set_event_handlers({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_and_hide_search();
|
on_sidebar_channel_click(stream_id, null, show_channel_feed);
|
||||||
show_channel_feed(stream_id, "sidebar enter key");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
keydown_util.handle({
|
keydown_util.handle({
|
||||||
|
|||||||
@@ -527,14 +527,14 @@ test_ui("narrowing", ({mock_template}) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test_ui("focusout_user_filter", () => {
|
test_ui("focusout_user_filter", () => {
|
||||||
stream_list.set_event_handlers({narrow_show_channel_feed() {}});
|
stream_list.set_event_handlers({show_channel_feed() {}});
|
||||||
const e = {};
|
const e = {};
|
||||||
const click_handler = $(".stream-list-filter").get_on_handler("focusout");
|
const click_handler = $(".stream-list-filter").get_on_handler("focusout");
|
||||||
click_handler(e);
|
click_handler(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
test_ui("focus_user_filter", () => {
|
test_ui("focus_user_filter", () => {
|
||||||
stream_list.set_event_handlers({narrow_show_channel_feed() {}});
|
stream_list.set_event_handlers({show_channel_feed() {}});
|
||||||
|
|
||||||
initialize_stream_data();
|
initialize_stream_data();
|
||||||
stream_list.build_stream_list();
|
stream_list.build_stream_list();
|
||||||
|
|||||||
Reference in New Issue
Block a user