Our application is a unique HTML5/WinJS Google Talk app tailored for Windows 8 users. Within our app, we utilize a textarea for chat input with a predefined maximum height. We have coded the height to automatically adjust to the maximum limit once reached.
However, we encountered an issue when testing the app on Windows 8.1. Every time the oninput
is triggered, the height increases by 3 pixels with each character typed. This causes the textarea to expand continuously, even for short inputs that do not require a new line. It seems that the scrollHeight or height properties are not updating correctly in Windows 8.1.
<textarea class="inputField" id="inputField" placeholder="Type your message"></textarea>
onMessageInput: function (e) {
e.target.style.height = (e.target.scrollHeight - 5) + "px";
if (e.target.clientHeight >= 350) {
e.target.style.overflowY = "scroll";
}
else {
e.target.style.overflowY = "hidden";
}
}.bind(this)
This function is linked to the oninput event, where we check if the client height exceeds 350 pixels and adjust the overflow property accordingly.
.inputField {
-ms-grid-row: 2;
-ms-grid-column: 2;
font-size: 19px;
height: 30px;
min-height: 30px;
max-height: 350px;
overflow: hidden;
}
To address the discrepancy in height, we added " - 5" to adjust the scrollHeight value by 5 pixels. This was a temporary workaround that we implemented. However, in Windows 8.1, clearing the text field (Ctrl-A then Backspace) does not reset the textarea height as it did in Windows 8.
We are seeking alternative approaches to handle this JavaScript-related issue more efficiently. Your suggestions and insights are highly appreciated!
Feel free to ask if you require more details or information!