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.

popover: Improve schedule reminder popover textarea behavior.

Amit Patil12b29a816fc7
diff --git a/web/src/compose_send_menu_popover.ts b/web/src/compose_send_menu_popover.ts
index 8ce6f4cee5f..e3e94392d22 100644
--- a/web/src/compose_send_menu_popover.ts
+++ b/web/src/compose_send_menu_popover.ts
@@ -1,3 +1,4 @@
+import autosize from "autosize";
import $ from "jquery";
import assert from "minimalistic-assert";
import * as tippy from "tippy.js";
@@ -83,6 +84,18 @@ export function open_schedule_message_menu(
);
}
const $popper = $(instance.popper);
+ const $reminder_note_textarea = $popper.find<HTMLTextAreaElement>(
+ "textarea.schedule-reminder-note",
+ );
+
+ if ($reminder_note_textarea.length > 0) {
+ $reminder_note_textarea.off("autosize:resized").on("autosize:resized", () => {
+ // Keep popper visible in viewport when textarea height increases.
+ void instance.popperInstance?.update();
+ });
+ autosize($reminder_note_textarea);
+ }
+
const message_schedule_callback = (time: string | number): void => {
if (remind_message_id !== undefined) {
do_schedule_reminder(
diff --git a/web/styles/app_variables.css b/web/styles/app_variables.css
index f14babbcce7..cb89c46180a 100644
--- a/web/styles/app_variables.css
+++ b/web/styles/app_variables.css
@@ -798,6 +798,7 @@
/* Input padding and border variables */
--input-horizontal-padding: 6px;
--input-vertical-padding: 4px;
+ --schedule-reminder-note-padding: 3px;
--input-border-width: 1px;
/* Message date divider variables */
diff --git a/web/styles/scheduled_messages.css b/web/styles/scheduled_messages.css
index e1b88cefa1b..121c6bef69b 100644
--- a/web/styles/scheduled_messages.css
+++ b/web/styles/scheduled_messages.css
@@ -21,13 +21,18 @@
}
.schedule-reminder-note {
- /* Horizontal resizing in the popover doesn't look good at all. */
- resize: vertical;
+ resize: none;
width: 100%;
min-width: 10em;
- padding: 3px;
- /* We set the minimum height of textarea to be enough for two lines of text. */
+ padding: var(--schedule-reminder-note-padding);
+ /* Set the minimum height such that we start out with 2 lines of text. */
min-height: calc(2em * var(--base-line-height-unitless));
+ /* Set the maximum height of textarea to be enough for 10 lines of text. */
+ max-height: calc(
+ (10em * var(--base-line-height-unitless)) +
+ (2 * var(--schedule-reminder-note-padding))
+ );
+ overflow-y: auto;
background-color: var(--background-color-textarea);