From 23a1929dddee8a8741870c51789017b8f3c76b7f Mon Sep 17 00:00:00 2001 From: Adrian Gruntkowski Date: Sat, 7 Dec 2024 20:17:29 +0100 Subject: [PATCH] Handle editable-area display resize better --- priv/static/js/components.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/priv/static/js/components.js b/priv/static/js/components.js index d3102bf..8476baf 100644 --- a/priv/static/js/components.js +++ b/priv/static/js/components.js @@ -23,6 +23,11 @@ class EditableArea extends HTMLElement { this.#sync(); }); + new ResizeObserver(() => { + this.inputElement.style.height = this.displayElement.scrollHeight + "px"; + this.inputElement.style.width = this.displayElement.scrollWidth + "px"; + }).observe(this.displayElement); + this.#updateReadonly(); this.#sync(); } @@ -87,8 +92,6 @@ class EditableArea extends HTMLElement { #sync() { this.displayElement.replaceChildren(...renderText(this.inputElement.value)); - this.inputElement.style.height = this.displayElement.scrollHeight + "px"; - this.inputElement.style.width = this.displayElement.scrollWidth + "px"; } }