compose: Disable unneeded control buttons in preview mode while editing.

This is a follow up to #26728, which disables buttons in preview mode
for any message being edited.

Care is taken to pass the correct preview state (compose vs the message
row being edited) to the popover menu so the buttons in it too can be
disabled as needed.
This commit is contained in:
N-Shar-ma
2023-09-14 19:39:33 +05:30
committed by Tim Abbott
parent 64d5547f26
commit 54b399ce96
3 changed files with 23 additions and 2 deletions

View File

@@ -361,6 +361,12 @@ export function initialize() {
const $row = rows.get_closest_row(e.target);
const $msg_edit_content = $row.find(".message_edit_content");
const content = $msg_edit_content.val();
// Disable unneeded compose_control_buttons as we don't
// need them in preview mode.
$row.addClass("preview_mode");
$row.find(".preview_mode_disabled .compose_control_button").attr("tabindex", -1);
$msg_edit_content.hide();
$row.find(".markdown_preview").hide();
$row.find(".undo_markdown_preview").show();
@@ -376,6 +382,12 @@ export function initialize() {
$("body").on("click", ".message_edit_form .undo_markdown_preview", (e) => {
e.preventDefault();
const $row = rows.get_closest_row(e.target);
// While in preview mode we disable unneeded compose_control_buttons,
// so here we are re-enabling those compose_control_buttons
$row.removeClass("preview_mode");
$row.find(".preview_mode_disabled .compose_control_button").attr("tabindex", 0);
$row.find(".message_edit_content").show();
$row.find(".undo_markdown_preview").hide();
$row.find(".preview_message_area").hide();