Textarea wrap=hard: The behavior differs from Chrome. Unintended line breaks are inserted.
Categories
(Core :: Layout: Form Controls, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox-esr115 | --- | unaffected |
| firefox-esr140 | --- | unaffected |
| firefox145 | --- | wontfix |
| firefox146 | --- | wontfix |
| firefox147 | --- | wontfix |
| firefox148 | --- | verified |
| firefox149 | --- | verified |
People
(Reporter: alice0775, Assigned: emilio)
References
Details
(Keywords: nightly-community)
Attachments
(3 files)
|
702 bytes,
text/html
|
Details | |
|
1.16 KB,
text/html
|
Details | |
|
48 bytes,
text/x-phabricator-request
|
dmeehan
:
approval-mozilla-beta+
|
Details | Review |
STR:
- download the attached textcase.html to local disk.
- Open downloaded textcase.html
- Paste the following text to the textarea
.2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8
.2.4.6.8 2.4.6.8 2.4.6.8
.2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8
- click
Actual Results:
- Before Bug 2002971
.2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8
.2.4.6.8 2.4.6.8 2.4.6.8
.2.4.6.8 2.4.6.8 2.4.6.8
2.4.6.8 2.4.6.8
- After Bug 2002971
.2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8
.2.4.6.8 2.4.6.8 2.4.6.8
.2.4.6.8 2.4.6.8 2.4.6.8
2.4.6.8 2.4.6.8
Expected Results: (Chrome does)
.2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8
.2.4.6.8 2.4.6.8 2.4.6.8
.2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8 2.4.6.8
So, Bug 2002971 does not fix this the extra line break in some case.
| Reporter | ||
Updated•9 months ago
|
Updated•9 months ago
|
| Reporter | ||
Comment 2•9 months ago
|
||
Here, a more realistic example: hard-wrap at 80 columns.
STR:
- Paste the following text to the textarea
function loadError(oError) {
throw new URIError(`The script ${oError.target.src} didn't load correctly.`);
}
function prefixScript(url, onloadFunction) {
const newScript = document.createElement("script");
newScript.onerror = loadError;
if (onloadFunction) {
newScript.onload = onloadFunction;
}
document.currentScript.parentNode.insertBefore(
newScript,
document.currentScript,
);
newScript.src = url;
}
- click
AR:
/*Let's create a function that imports new scripts within a document creating a
<script> node immediately before the <script> that hosts the following code. */
function loadError(oError) {
throw new URIError(`The script
${oError.target.src} didn't load correctly.`);
}
function prefixScript(url,
onloadFunction) {
const newScript = document.createElement("script");
newScript.onerror = loadError;
if (onloadFunction) {
newScript.onload =
onloadFunction;
}
document.currentScript.parentNode.insertBefore(
newScript,
document.currentScript,
);
newScript.src = url;
}
ER:
In this case, only the first line of the comment should be hard-wrapped.
Each line in the section of JavaScript code is already under 80 columns, so no additional line breaks should be needed.
<script> node immediately before the <script> that hosts the following code. */
function loadError(oError) {
throw new URIError(`The script ${oError.target.src} didn't load correctly.`);
}
function prefixScript(url, onloadFunction) {
const newScript = document.createElement("script");
newScript.onerror = loadError;
if (onloadFunction) {
newScript.onload = onloadFunction;
}
document.currentScript.parentNode.insertBefore(
newScript,
document.currentScript,
);
newScript.src = url;
}
| Reporter | ||
Updated•9 months ago
|
| Reporter | ||
Comment 3•9 months ago
•
|
||
Input the following text into testcase2.html. then click
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
aaaaa
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
AR:
The long sentence on the second line breaks at an unintended point.
if the input text contains pre-formatted lines(here aaaaa\d\n) shorter than the default, subsequent longer lines may break unexpectedly.
Apparently, The length of a pre-formatted short line and the length immediately preceding a line are incorrectly considered when determining the break position for the next long line.
From what I saw, if you use Wrap=Hard and Cols=75 then it will put a line break in at 75 (73 chars + 2 for CR code) even if this covers several lines of text.
In other words, instead of it reading Cols=75 as "put CR in at 75 chars if NOT already had one by then", it appears to be reading it as "put a CR in at 75 chars even if its already had one before then" and then after putting in one of these unneeded extra CR's, it starts counting back up to 75 again before putting in another unneeded CR (with slight adjustment to add the CR code itself).
In terms of versions, I've heard reports it works normally on Firefox v144, but failing on Firefox v145, suggesting it may be something new with v145. However none of the changes listed in v145 obviously relate, so unclear why that would be the case.
Comment 5•8 months ago
|
||
I can confirm that we're seeing unintended breaks in textareas with the new wrap=hard behavior in firefox. For us, the new behavior is unfortunately worse than when wrap=hard didn't work at all.
What we're seeing matches the behavior that RobD and Alice0775 White outlined.
| Assignee | ||
Comment 7•7 months ago
|
||
Sorry for the lag, I've been swamped with other higher priority work. Looking at this now.
| Assignee | ||
Comment 8•7 months ago
|
||
Turns out there are still various issues:
-
There's this "bonus width" thing which might make us actually not
hard-wrap. Add an option to ignore it. -
Even though \n does create a breaking opportunity, we don't
force-break. Do deal with each line at a time instead.
It's technically a bit more inefficient (two passes over the string),
but seems fine and it's simpler / easier to prove correct.
Add a few extra tests too.
| Assignee | ||
Updated•7 months ago
|
Comment 11•7 months ago
|
||
| bugherder | ||
Comment 12•7 months ago
|
||
Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.
Comment 14•7 months ago
|
||
The patch landed in nightly and beta is affected.
:emilio, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta approval.
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.
- If no, please set
status-firefox148towontfix.
For more information, please visit BugBot documentation.
| Assignee | ||
Comment 15•7 months ago
|
||
Comment on attachment 9538296 [details]
Bug 2003109 - Improve textarea hard-wrapping further. r=smaug,#dom-core
Beta/Release Uplift Approval Request
- User impact if declined/Reason for urgency: Regression with duplicates, and we're early-ish in the cycle.
- Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: Yes
- Needs manual test from QE?: Yes
- If yes, steps to reproduce: comment 2 is a realistic test-case.
- List of other uplifts needed: none
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): Change only affects this feature and nothing else.
- String changes made/needed: none
- Is Android affected?: Yes
| Assignee | ||
Updated•7 months ago
|
Updated•7 months ago
|
Comment 16•7 months ago
|
||
Comment on attachment 9538296 [details]
Bug 2003109 - Improve textarea hard-wrapping further. r=smaug,#dom-core
Approved for 148.0b6
Updated•7 months ago
|
Comment 17•7 months ago
|
||
| uplift | ||
Updated•7 months ago
|
Comment 18•7 months ago
|
||
Verified fixed using Nightly 149.0a1 (20260122072819) and Beta 148.0b6 (20260121193655) on Windows 11, MacOS 15 and Ubuntu 24.04.
Updated•7 months ago
|
Description
•