mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user