Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 6 years ago

#9161 closed defect (bug) (fixed)

edInsertContent doesn't remember scrollTop property

Reported by: gmpfree's profile gmpfree Owned by: azaozz's profile 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)

#1 @gmpfree
16 years ago

this bug has been around for a quite sometime, edInsertTag(handles link insertion) remember scrollTop but edInsertContent(handles image insertion) doesn't.

#2 @azaozz
16 years ago

  • Milestone changed from 2.7.2 to 2.8

#3 @azaozz
16 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10745]) Remember scrollTop in Quicktags, props gmpfree, fixes #9161

This ticket was mentioned in Slack in #core-editor by mcsf. View the logs.


6 years ago

Note: See TracTickets for help on using tickets.