Fix textarea resize for editing messages.

Reusing code from the main compose_message component so that resizing now
behaves correctly. This means that when the user tries to resize vertically,
the autoresize code is disabled, and the textbox reverts to manual resizing.
Fixes #4573
This commit is contained in:
Cory Lynch
2017-04-22 16:34:18 -04:00
committed by Tim Abbott
parent 90a154e451
commit f9d1bff167
4 changed files with 35 additions and 29 deletions

View File

@@ -598,35 +598,7 @@ exports.validate = function () {
};
$(function () {
(function on_compose_resize(cb) {
var meta = {
compose_box: document.querySelector("#new_message_content"),
height: null,
mousedown: false,
};
meta.compose_box.addEventListener("mousedown", function () {
meta.mousedown = true;
meta.height = meta.compose_box.clientHeight;
});
// If the user resizes the compose box manually, we use the
// callback to stop autosize from adjusting the compose box height.
document.body.addEventListener("mouseup", function () {
if (meta.mousedown === true) {
meta.mousedown = false;
if (meta.height !== meta.compose_box.clientHeight) {
meta.height = meta.compose_box.clientHeight;
cb.call(meta.compose_box, meta.height);
}
}
});
}(function (height) {
// This callback disables autosize on the compose box. It
// will be re-enabled when the compose box is next opened.
$("#new_message_content").trigger("autosize.destroy")
.height(height + "px");
}));
resize.watch_manual_resize("#new_message_content");
// Run a feature test and decide whether to display
// the "Attach files" button