mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 02:48:00 +00:00
compose: Fix preview not being updated when compose textarea is updated.
In preview mode, background updates to the compose box don’t refresh the preview. For example, canceling an ongoing file upload after activating preview mode still displays "uploading." This commit extracts the preview rendering logic from the show_preview_area function into a new function, `render_preview_area`, and calls it on the compose textarea’s change event to ensure the preview updates whenever the textarea is modified. However, this introduces a race condition where the latest request is not always reflected in the preview. To resolve this, we introduce a state variable, `preview_render_count`, which is used to ensure only the latest preview update is applied. Fixes #33589.
This commit is contained in:
@@ -80,6 +80,9 @@ export function initialize() {
|
||||
});
|
||||
|
||||
$("textarea#compose-textarea").on("input propertychange", () => {
|
||||
if ($("#compose").hasClass("preview_mode")) {
|
||||
compose.render_preview_area();
|
||||
}
|
||||
compose_validate.warn_if_topic_resolved(false);
|
||||
const compose_text_length = compose_validate.check_overflow_text($("#send_message_form"));
|
||||
if (compose_text_length !== 0 && $("textarea#compose-textarea").hasClass("invalid")) {
|
||||
|
||||
Reference in New Issue
Block a user