Closed
Bug 231389
Opened 20 years ago
Closed 14 years ago
Textarea scrolls to top after changing its .value, regardless of cursor position
Categories
(Core :: DOM: Editor, defect)
Tracking
()
RESOLVED
FIXED
mozilla1.9.3a4
People
(Reporter: moeller, Assigned: ehsan.akhgari)
References
()
Details
Attachments
(2 files, 4 obsolete files)
1.35 KB,
text/html
|
Details | |
3.22 KB,
patch
|
roc
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624, also tested with Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7a) Gecko/20040111 Firebird/0.8.0+ After changing the value of a textarea via JavaScript, it scrolls to the top. If the cursor is subsequently set via selectionStart/selectionEnd or setSelectionRange(a,b), the cursor itself is correctly set, but the textarea view is still at the top. Calls to focus() make no difference either. This affects comment formatting toolbars, where we want to change the selection to apply tags like "bold" and "italic" around it. This works as long as the selection is not beyond the textarea visible range, i.e. as long as no scrolling is required to make it. Any selection that goes beyond that triggers the bug: the textarea scrolls to the top after its contents are overwritten. Reproducible: Always Steps to Reproduce: 1. Go to http://test.wikipedia.org/w/wiki.phtml?title=Main_Page&action=edit 2. Scroll to the bottom 3. Select some text 4. Click the "bold" button Actual Results: Textarea view scrolls to top. When you press a non-dead key, you're in the right position again (the cursor is correctly set in this script). Expected Results: Textarea view should not have scrolled, or there should be a JavaScript method to change the selection text without scrolling. The script used is at http://test.wikipedia.org/style/wikibits.js
Reporter | ||
Comment 1•20 years ago
|
||
Another example: http://www.massless.org/mozedit/
![]() |
||
Comment 2•20 years ago
|
||
> After changing the value of a textarea via JavaScript, it scrolls to the top. This part is correct -- you have wiped out the old text completely, so the old insertion point is lost. > cursor itself is correctly set, but the textarea view is still at the top That sounds like a bug. Over to editor core. If you could attach a testcase to this bug, that would be great.
Assignee: general → mozeditor
Component: DOM: Level 0 → Editor: Core
QA Contact: ian → sairuh
Reporter | ||
Comment 3•20 years ago
|
||
Reporter | ||
Comment 4•20 years ago
|
||
Does this help, Boris?
Reporter | ||
Comment 6•20 years ago
|
||
JavaScript that solves this problem
Comment 7•20 years ago
|
||
This patch has the textarea scroll the cursor into view whenever the selection changes. This seems to be the appropriate behavior. With it the above workaround is no longer required.
Comment 8•20 years ago
|
||
Comment on attachment 151619 [details] [diff] [review] Patch to fix the problem w/o a workaround The workaround worked, but this is nicer.
Attachment #151619 -
Flags: review?(pinkerton)
Comment 9•20 years ago
|
||
Comment on attachment 151619 [details] [diff] [review] Patch to fix the problem w/o a workaround r=pink, though i know nothing about this code ;)
Attachment #151619 -
Flags: review?(pinkerton) → review+
Comment 10•20 years ago
|
||
Comment on attachment 151619 [details] [diff] [review] Patch to fix the problem w/o a workaround >+ rv = selection->AddRange(range); >+ // scroll the new selection into view >+ // ignore any scrolling errors. >+ mTextSelImpl->ScrollSelectionIntoView(nsISelectionController::SELECTION_NORMAL, >+ nsISelectionController::SELECTION_FOCUS_REGION, PR_TRUE); >+ return rv; You should probably test rv before the call to ScrollSelectionIntoView, return it if NS_FAILED(rv) and return NS_OK after the call.
Comment 11•20 years ago
|
||
Sorry for being untutored about these things, but how does one install the attachment so that it will fix the bug? This bug has been driving me crazy for months & I'd dearly love to fix it. Are you perhaps in a testing stage & will reveal this fix & installation protocols later?
Comment 12•20 years ago
|
||
d/l & extract http://ftp.mozilla.org/pub/mozilla.org/mozilla/nightly/latest/mozilla-source.tar.bz2 apply patch using http://www.mozilla.org/build/unix-cheatsheet.html#applyPatch make .mozconfig using http://webtools.mozilla.org/build/config.cgi `make -f client.mk build` if you need any other help contact irc://moznet/#mozillazine
Comment 13•20 years ago
|
||
(In reply to comment #12) > d/l & extract > http://ftp.mozilla.org/pub/mozilla.org/mozilla/nightly/latest/mozilla-source.tar.bz2 > apply patch using http://www.mozilla.org/build/unix-cheatsheet.html#applyPatch > make .mozconfig using http://webtools.mozilla.org/build/config.cgi > `make -f client.mk build` > if you need any other help contact irc://moznet/#mozillazine when I try to save the .tar file to my desktop & open it w. winzip I get an error saying it cannot open the file since it doesn't appear to be a legitimate archive file. I don't understand how one's supposed to use the Unix Configurator. Also, don't understand how to follow the patch cheatsheet instructions. I'm still totally confused about what one needs to do to fix the problem or whether it's even possible to do so.
Comment 14•20 years ago
|
||
Now checking the return value per comments. Not using NS_ENSURE_SUCCESS as this really isn't the sort of place we'd want to assert.
Updated•20 years ago
|
Attachment #151619 -
Attachment is obsolete: true
Comment 15•20 years ago
|
||
Sorry Richard, I thought you where the reporter who is using Linux. You can patch/compile Mozilla using the instructions located at http://www.mozilla.org/build/win32.html. This option is the most difficult of the two and it will take hours to finish. Your second option is to wait untill this patch is checked in to the tree. When this happens, the next nightly will have this patch. The nightlys are located at http://ftp.mozilla.org/pub/mozilla.org/mozilla/nightly/latest/.
Updated•20 years ago
|
Attachment #151854 -
Flags: review?(pinkerton)
Updated•20 years ago
|
OS: Linux → All
Comment 16•19 years ago
|
||
Comment on attachment 151854 [details] [diff] [review] Patch v2 again, r=pink but i'm not the best person to review this.
Attachment #151854 -
Flags: review?(pinkerton) → review+
Comment 17•19 years ago
|
||
Tom Hennen: Do you plan land it in 1.8 timeframe? What's next step on this way, if Mike Pinkerton review your last patch?
Comment 18•19 years ago
|
||
Not sure if this is relevant to the code, but since only selectionStart is considered when scrolling the selection into view, perhaps only the code for scrolling selection into view should be called only if selectionStart has changed. That would happen when setting selectionStart to a different value or setting selectionEnd to a value less than selectionStart. A little optimization.
Comment 19•19 years ago
|
||
A case where the JS workaround is still needed even if patch is checked in: 1) Enter enough text to make the scroll bar appear. 2) Select some text or a position in the text, so that the selection's y-position is greater than clientHeight. 3) Scroll down a bit, so that the selected text is still in view. Denote current scrollTop as A. 4) Set value. scrollTop=selectionStart=selectionEnd=0. 5) Set selectionStart/selectionEnd. The textarea scrolls until the selected text is in view. The selection should be displayed at the bottom of the textarea. However the new scroll position is not A - at position A, the selection should not appear at the bottom of the textarea. Is this intended?
Comment 20•18 years ago
|
||
Requesting attention / blocking for 2.0 via IRC request.
Flags: blocking1.8.1?
Comment 21•18 years ago
|
||
Not going to block 1.8.1 for this, but we'd happily consider a patch once it has baked on the trunk.
Flags: blocking1.8.1? → blocking1.8.1-
Updated•17 years ago
|
QA Contact: bugzilla → editor
Updated•17 years ago
|
Assignee: mozeditor → nobody
Comment 22•16 years ago
|
||
Updated patch, works for me ;)
Assignee | ||
Comment 23•14 years ago
|
||
Patch + test.
Assignee: nobody → ehsan.akhgari
Attachment #145368 -
Attachment is obsolete: true
Attachment #151854 -
Attachment is obsolete: true
Attachment #289312 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #432855 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 24•14 years ago
|
||
Comment on attachment 432855 [details] [diff] [review] Patch (v1) bz's out, switching the review request to roc.
Attachment #432855 -
Flags: review?(bzbarsky) → review?(roc)
Attachment #432855 -
Flags: review?(roc) → review+
Assignee | ||
Comment 25•14 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/ba70a0cb9240
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a4
You need to log in
before you can comment on or make changes to this bug.
Description
•