message_preview: Don't needlessly show/hide compose textarea.

Because the compose-box resize logic is tied to the size of the
textarea, it's possible when resizing in preview mode that the
state of the compose box is not properly tracked. That's because
the height logic in `autosize_message_content` assumes a visible
textarea.

However, because both the textarea and the message preview area
occupy the same named grid area (`message-content`), and because
the preview area comes after the textarea in the DOM, when visible,
the preview area will automatically cover (and be sized to) the
textarea. And because the textarea remains observable in the DOM,
the compose box will obey the same expansion logic in preview mode
as it does in edit mode.
This commit is contained in:
Karl Stolley 2024-07-31 10:41:06 -05:00 committed by Tim Abbott
parent 604e328038
commit df04c4c1f9
2 changed files with 0 additions and 9 deletions

View File

@ -39,7 +39,6 @@ export function clear_private_stream_alert() {
}
export function clear_preview_area() {
$("textarea#compose-textarea").show();
$("textarea#compose-textarea").trigger("focus");
$("#compose .undo_markdown_preview").hide();
$("#compose .preview_message_area").hide();
@ -60,7 +59,6 @@ export function show_preview_area() {
$("#compose .preview_mode_disabled .compose_control_button").attr("tabindex", -1);
const content = $("textarea#compose-textarea").val();
$("textarea#compose-textarea").hide();
$("#compose .markdown_preview").hide();
$("#compose .undo_markdown_preview").show();
$("#compose .undo_markdown_preview").trigger("focus");

View File

@ -405,7 +405,6 @@ test_ui("enter_with_preview_open", ({override, override_rewire}) => {
compose_state.set_stream_id(social.stream_id);
$("textarea#compose-textarea").val("message me");
$("textarea#compose-textarea").hide();
$("#compose .undo_markdown_preview").show();
$("#compose .preview_message_area").show();
$("#compose .markdown_preview").hide();
@ -416,7 +415,6 @@ test_ui("enter_with_preview_open", ({override, override_rewire}) => {
send_message_called = true;
});
compose.enter_with_preview_open();
assert.ok($("textarea#compose-textarea").visible());
assert.ok(!$("#compose .undo_markdown_preview").visible());
assert.ok(!$("#compose .preview_message_area").visible());
assert.ok($("#compose .markdown_preview").visible());
@ -490,7 +488,6 @@ test_ui("finish", ({override, override_rewire}) => {
send_message_called = true;
});
assert.ok(compose.finish());
assert.ok($("textarea#compose-textarea").visible());
assert.ok(!$("#compose .undo_markdown_preview").visible());
assert.ok(!$("#compose .preview_message_area").visible());
assert.ok($("#compose .markdown_preview").visible());
@ -657,7 +654,6 @@ test_ui("on_events", ({override, override_rewire}) => {
(function test_markdown_preview_compose_clicked() {
// Tests setup
function setup_visibilities() {
$("textarea#compose-textarea").show();
$("#compose .markdown_preview").show();
$("#compose .undo_markdown_preview").hide();
$("#compose .preview_message_area").hide();
@ -665,7 +661,6 @@ test_ui("on_events", ({override, override_rewire}) => {
}
function assert_visibilities() {
assert.ok(!$("textarea#compose-textarea").visible());
assert.ok(!$("#compose .markdown_preview").visible());
assert.ok($("#compose .undo_markdown_preview").visible());
assert.ok($("#compose .preview_message_area").visible());
@ -785,7 +780,6 @@ test_ui("on_events", ({override, override_rewire}) => {
(function test_undo_markdown_preview_clicked() {
const handler = $("#compose").get_on_handler("click", ".undo_markdown_preview");
$("textarea#compose-textarea").hide();
$("#compose .undo_markdown_preview").show();
$("#compose .preview_message_area").show();
$("#compose .markdown_preview").hide();
@ -806,7 +800,6 @@ test_ui("on_events", ({override, override_rewire}) => {
handler(event);
assert.ok($("textarea#compose-textarea").visible());
assert.ok(!$("#compose .undo_markdown_preview").visible());
assert.ok(!$("#compose .preview_message_area").visible());
assert.ok($("#compose .markdown_preview").visible());