Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose: Show or hide scrolling buttons on scroll event.
Karl Stolleydcb7acfde3f1
diff --git a/web/src/compose_setup.js b/web/src/compose_setup.jsindex 13e9d8c5bf4..0eaa40435f6 100644--- a/web/src/compose_setup.js+++ b/web/src/compose_setup.js@@ -1,4 +1,5 @@import $ from "jquery";+import _ from "lodash";import {unresolve_name} from "../shared/src/resolved_topic.ts";import render_add_poll_modal from "../templates/add_poll_modal.hbs";@@ -508,6 +509,13 @@ export function initialize() {}});+ $(".compose-scrollable-buttons").on(+ "scroll",+ _.throttle((e) => {+ compose_ui.handle_scrolling_formatting_buttons(e);+ }, 150),+ );+$("#compose_recipient_box").on("click", "#recipient_box_clear_topic_button", () => {const $input = $("input#stream_message_recipient_topic");$input.val("");diff --git a/web/src/compose_ui.ts b/web/src/compose_ui.tsindex e31d0a88b0b..5d6f1c261df 100644--- a/web/src/compose_ui.ts+++ b/web/src/compose_ui.ts@@ -530,6 +530,31 @@ export function make_compose_box_original_size(): void {$("textarea#compose-textarea").trigger("focus");}+export function handle_scrolling_formatting_buttons(event: JQuery.ScrollEvent): void {+ event.stopPropagation();+ const $button_bar = $(event.currentTarget);+ const $button_container = $button_bar.closest(".compose-scrolling-buttons-container");+ const button_bar_max_left_scroll = Number(+ $button_container.attr("data-button-bar-max-left-scroll"),+ );+ const button_bar_left_scroll = $button_bar.scrollLeft();++ // If we're within 4px of the start or end of the formatting buttons,+ // go ahead and hide the respective scrolling button+ const hide_scroll_button_threshhold_px = 4;++ $button_container.addClass("can-scroll-forward can-scroll-backward");++ assert(typeof button_bar_left_scroll === "number");++ if (button_bar_left_scroll >= button_bar_max_left_scroll - hide_scroll_button_threshhold_px) {+ $button_container.removeClass("can-scroll-forward");+ }+ if (button_bar_left_scroll <= hide_scroll_button_threshhold_px) {+ $button_container.removeClass("can-scroll-backward");+ }+}+export function handle_keydown(event: JQuery.KeyboardEventBase,$textarea: JQuery<HTMLTextAreaElement>,diff --git a/web/src/message_edit.ts b/web/src/message_edit.tsindex 9e1e0357f6e..90900c0204c 100644--- a/web/src/message_edit.ts+++ b/web/src/message_edit.ts@@ -1,5 +1,6 @@import ClipboardJS from "clipboard";import $ from "jquery";+import _ from "lodash";import assert from "minimalistic-assert";import {z} from "zod";@@ -518,6 +519,8 @@ function edit_message($row: JQuery, raw_content: string): void {}),);+ const $button_bar = $form.find(".compose-scrollable-buttons");+const $message_edit_content = $form.find<HTMLTextAreaElement>("textarea.message_edit_content");assert($message_edit_content.length === 1);currently_editing_messages.set(message.id, $message_edit_content);@@ -549,6 +552,13 @@ function edit_message($row: JQuery, raw_content: string): void {.find(".message-edit-feature-group .audio_link").toggle(compose_call.compute_show_audio_chat_button());+ $button_bar.on(+ "scroll",+ _.throttle((e: JQuery.ScrollEvent) => {+ compose_ui.handle_scrolling_formatting_buttons(e);+ }, 150),+ );+const $message_edit_countdown_timer = $row.find(".message_edit_countdown_timer");const $copy_message = $row.find(".copy_message");