Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

scroll_to_bottom_button: Clear the hide timer before starting another.

Aman Agrawal696ae1e2a405
diff --git a/web/src/scroll_to_bottom_button.ts b/web/src/scroll_to_bottom_button.ts
index 07c1735b570..ee65c777b29 100644
--- a/web/src/scroll_to_bottom_button.ts
+++ b/web/src/scroll_to_bottom_button.ts
@@ -25,6 +25,7 @@ export function hide_scroll_to_bottom(): void {
return;
}
+ clearInterval(hide_scroll_to_bottom_timer);
hide_scroll_to_bottom_timer = setInterval(() => {
// Check if the user is hovered over the scroll-to-bottom
// button every 3 seconds to allow time for interaction.
diff --git a/web/tests/scroll_to_bottom_button.test.cjs b/web/tests/scroll_to_bottom_button.test.cjs
index 2b30f6d6708..6aedfc15264 100644
--- a/web/tests/scroll_to_bottom_button.test.cjs
+++ b/web/tests/scroll_to_bottom_button.test.cjs
@@ -137,6 +137,23 @@ test("another mouse scroll restarts the three seconds", ({override}) => {
assert.ok(!is_shown());
});
+test("a keyboard scroll does not make a later hide come early", ({override}) => {
+ set_feed(override, {bottom_visible: false});
+ mouse_scroll();
+
+ clock.tick(1000);
+ keydown();
+ scroll_to_bottom_button.hide_scroll_to_bottom();
+
+ clock.tick(4500);
+ mouse_scroll();
+ clock.tick(2999);
+ assert.ok(is_shown());
+
+ clock.tick(1);
+ assert.ok(!is_shown());
+});
+
test("hidden by a keypress without modifiers", () => {
for (const modifier of ["shiftKey", "ctrlKey", "metaKey"]) {
$container().addClass("show");