From f244c2eca462996d6ebbc8722547103239015289 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 28 Feb 2022 15:25:41 -0800 Subject: [PATCH] Revert "drafts: Use simplebar for scrollbar." This reverts commit f3964673e7b11c32c14f2355c949a2c76178545f. It broke drafts_scroll by confusing jQuery object APIs with DOM element APIs. Signed-off-by: Anders Kaseorg --- static/js/drafts.js | 12 +++++------- static/styles/drafts.css | 1 - static/templates/draft_table_body.hbs | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/static/js/drafts.js b/static/js/drafts.js index a7cd043afd..6ace0068e9 100644 --- a/static/js/drafts.js +++ b/static/js/drafts.js @@ -26,7 +26,6 @@ import * as rendered_markdown from "./rendered_markdown"; import * as stream_data from "./stream_data"; import * as sub_store from "./sub_store"; import * as timerender from "./timerender"; -import * as ui from "./ui"; import * as ui_util from "./ui_util"; import * as util from "./util"; @@ -499,22 +498,21 @@ function drafts_scroll(next_focus_draft_row) { } activate_element(next_focus_draft_row[0].children[0]); - const scroll_element = ui.get_scroll_element($(".drafts-list")); - // If focused draft is first draft, scroll to the top. if ($(".draft-info-box").first()[0].parentElement === next_focus_draft_row[0]) { - scroll_element.scrollTop = 0; + $(".drafts-list")[0].scrollTop = 0; } // If focused draft is the last draft, scroll to the bottom. if ($(".draft-info-box").last()[0].parentElement === next_focus_draft_row[0]) { - scroll_element.scrollTop = scroll_element.scrollHeight - scroll_element.height(); + $(".drafts-list")[0].scrollTop = + $(".drafts-list")[0].scrollHeight - $(".drafts-list").height(); } // If focused draft is cut off from the top, scroll up halfway in draft modal. if (next_focus_draft_row.position().top < 55) { // 55 is the minimum distance from the top that will require extra scrolling. - scroll_element.scrollTop -= scroll_element.clientHeight / 2; + $(".drafts-list")[0].scrollTop -= $(".drafts-list")[0].clientHeight / 2; } // If focused draft is cut off from the bottom, scroll down halfway in draft modal. @@ -523,7 +521,7 @@ function drafts_scroll(next_focus_draft_row) { const dist_from_bottom = $(".drafts-container")[0].clientHeight - total_dist; if (dist_from_bottom < -4) { // -4 is the min dist from the bottom that will require extra scrolling. - scroll_element.scrollTop += scroll_element.clientHeight / 2; + $(".drafts-list")[0].scrollTop += $(".drafts-list")[0].clientHeight / 2; } } diff --git a/static/styles/drafts.css b/static/styles/drafts.css index 1c51e1199f..1b9e23fbdb 100644 --- a/static/styles/drafts.css +++ b/static/styles/drafts.css @@ -52,7 +52,6 @@ .drafts-list { padding: 10px 0; overflow: auto; - height: 100%; .no-drafts { display: block; diff --git a/static/templates/draft_table_body.hbs b/static/templates/draft_table_body.hbs index c180d4fa78..2f1d4f6d42 100644 --- a/static/templates/draft_table_body.hbs +++ b/static/templates/draft_table_body.hbs @@ -14,7 +14,7 @@ {{t "Pro tip: You can use 'd' to open your drafts."}} -
+
{{t 'No drafts.'}}