Editor: prevent jumping when using the backspace button in the Text editor in Firefox and IE.
Fixes #37072. git-svn-id: https://develop.svn.wordpress.org/trunk@37684 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b9d46425c0
commit
e65a667c9c
|
@ -86,17 +86,21 @@
|
||||||
|
|
||||||
var length = textEditor.value.length;
|
var length = textEditor.value.length;
|
||||||
var height = parseInt( textEditor.style.height, 10 );
|
var height = parseInt( textEditor.style.height, 10 );
|
||||||
|
var top = window.scrollTop;
|
||||||
|
|
||||||
if ( length < oldTextLength ) {
|
if ( length < oldTextLength ) {
|
||||||
// textEditor.scrollHeight is not adjusted until the next line.
|
// textEditor.scrollHeight is not adjusted until the next line.
|
||||||
textEditor.style.height = 'auto';
|
textEditor.style.height = 'auto';
|
||||||
|
|
||||||
if ( textEditor.scrollHeight >= autoresizeMinHeight ) {
|
if ( textEditor.scrollHeight > autoresizeMinHeight ) {
|
||||||
textEditor.style.height = textEditor.scrollHeight + 'px';
|
textEditor.style.height = textEditor.scrollHeight + 'px';
|
||||||
} else {
|
} else {
|
||||||
textEditor.style.height = autoresizeMinHeight + 'px';
|
textEditor.style.height = autoresizeMinHeight + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent scroll-jumping in Firefox and IE.
|
||||||
|
window.scrollTop = top;
|
||||||
|
|
||||||
if ( textEditor.scrollHeight < height ) {
|
if ( textEditor.scrollHeight < height ) {
|
||||||
adjust();
|
adjust();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue