You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but I found the two issues are still there after I pulled the latest code:
When you input hello following many line breaks, aka \n\n\n, you can see the cursor pointer goes up still
if you intput many line breaks, you can see the height of the textarea doesn't increase, instead it shows a scroll bar in the right side the text area.
I came back to the inital code before I made my PR #1359 , and make sure I understand every line of code. now let me explain the reason:
First, I have to say the solution in your codebase to calculate the row num is a genius solution! basically, it adds up 2 two values:
-- Copy the content from the textarea to a hidden span named __measure, then calcuate how many rows the content of __measure needs.
-- a second logic, count the number of \n, to get how many rows required by line breakers.
but the problem come from here, in which it sets the content of __measure:
so when the input content is \n\n\n\n\nn\n\nn\n\n, which makes dom.value.trim().length > 0 false, it sets the innerText of __measure to be "1" as in only one line. while the logic counting \n returns correct line count made by line breakers. adding these 2 values can result in correct row number for the text area.
however when the input content becomes hello\n\n\n\n\nn\n\nn\n\n, as dom.value.trim().length > 0 becomes ture, so the content of __measure is set to hello\n\n\n\n\nn\n\nn\n\n, in my tests, both Firefox and chrome honestly interpret each \n to be a <br>, which is a new line, so the line number calculated from __measure is already the actually row num for the input textarea. . after adding the line num from counting \n, well, the row number are duplicated.
Based on my researh that both firebox and chrome render \n correctly in __measure I think the fix can be allowing to set the contents like \n\n\n\n\nn\n\nn\n\n to __measure, let it calculate the row num only, without adding extra num by counting \n.
meanwhile , I am going create a new PR
The text was updated successfully, but these errors were encountered:
hI @Yidadaa , first let me say sorry that I didn't address the last issue in my PR #1359
I see you provided a fix 9b1f251 to this problem.
but I found the two issues are still there after I pulled the latest code:
When you input

hello
following many line breaks, aka\n\n\n
, you can see the cursor pointer goes up stillif you intput many line breaks, you can see the height of the textarea doesn't increase, instead it shows a scroll bar in the right side the text area.

I came back to the inital code before I made my PR #1359 , and make sure I understand every line of code. now let me explain the reason:
First, I have to say the solution in your codebase to calculate the row num is a genius solution! basically, it adds up 2 two values:
-- Copy the content from the textarea to a hidden
span
named__measure
, then calcuate how many rows the content of__measure
needs.-- a second logic, count the number of
\n
, to get how many rows required by line breakers.but the problem come from here, in which it sets the content of
__measure
:so when the input content is
\n\n\n\n\nn\n\nn\n\n
, which makesdom.value.trim().length > 0
false, it sets theinnerText
of__measure
to be"1"
as in only one line. while the logic counting\n
returns correct line count made by line breakers. adding these 2 values can result in correct row number for the text area.however when the input content becomes
hello\n\n\n\n\nn\n\nn\n\n
, asdom.value.trim().length > 0
becomesture
, so the content of__measure
is set tohello\n\n\n\n\nn\n\nn\n\n
, in my tests, both Firefox and chrome honestly interpret each\n
to be a<br>
, which is a new line, so the line number calculated from__measure
is already the actually row num for the input textarea. . after adding the line num from counting\n
, well, the row number are duplicated.Based on my researh that both firebox and chrome render
\n
correctly in__measure
I think the fix can be allowing to set the contents like\n\n\n\n\nn\n\nn\n\n
to__measure
, let it calculate the row num only, without adding extra num by counting\n
.meanwhile , I am going create a new PR
The text was updated successfully, but these errors were encountered: