#9161 closed defect (bug) (fixed)
edInsertContent doesn't remember scrollTop property
Reported by: | gmpfree | Owned by: | azaozz |
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | trivial | Version: | |
Component: | JavaScript | Keywords: | |
Focuses: | Cc: |
Description
in wp-includes/js/quicktags.js
original:
function edInsertContent(myField, myValue) { //IE support if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; myField.focus(); } //MOZILLA/NETSCAPE support else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); myField.focus(); myField.selectionStart = startPos + myValue.length; myField.selectionEnd = startPos + myValue.length; } else { myField.value += myValue; myField.focus(); } }
fixed:
function edInsertContent(myField, myValue) { //IE support if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; myField.focus(); } //MOZILLA/NETSCAPE support else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; '''var scrollTop = myField.scrollTop;''' myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); myField.focus(); myField.selectionStart = startPos + myValue.length; myField.selectionEnd = startPos + myValue.length; '''myField.scrollTop = scrollTop;''' } else { myField.value += myValue; myField.focus(); } }
now insert image(via quicktag or upload manager) in plaintxt mode won't reset textarea scroll.
Change History (4)
Note: See
TracTickets for help on using
tickets.
this bug has been around for a quite sometime, edInsertTag(handles link insertion) remember scrollTop but edInsertContent(handles image insertion) doesn't.