Skip to content

Commit 28701bb

Browse files
committed
use the same value change detection as autosize package
1 parent d2b65b6 commit 28701bb

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

web_src/js/features/comp/ComboMarkdownEditor.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,9 @@ class ComboMarkdownEditor {
282282
this.textareaInitalHeight = this.textarea.offsetHeight;
283283
}
284284
const offset = this.textarea.offsetHeight - this.textarea.clientHeight;
285-
if (!this.lastValue || Math.abs(this.lastValue.length - this.textarea.value.length) > 2) {
286-
// the value has changed a lot, so reset the height to calculate the real scroll height, it might cause UI flickering
285+
if (!this.lastValue || !this.textarea.value.startsWith(this.lastValue)) {
286+
// the value has changed a lot, so reset the height to calculate the real scroll height, it's slow and might cause slight flickering.
287287
this.textarea.style.height = 'auto';
288-
} else {
289-
// try to shrink a little to see if a line is deleted (since the value doesn't change much), it won't cause UI flickering
290-
// the magic number is a general number which fits most line-height styles.
291-
this.textarea.style.height = `${this.textarea.scrollHeight + offset - 40}px`;
292288
}
293289
// make sure the height is not smaller than the initial height
294290
this.textarea.style.height = `${Math.max(this.textareaInitalHeight, this.textarea.scrollHeight + offset)}px`;

0 commit comments

Comments
 (0)