Editor: When switching Editor tabs, don't scroll unnecessarily.
- When switching to the Text view, wait until after the Visual editor element has been hidden, before focussing the `<textarea>`. - When switching to the Visual view, only scroll if the cursor is not visible on the current screen. Fixes #42530. Built from https://develop.svn.wordpress.org/trunk@42175 git-svn-id: http://core.svn.wordpress.org/trunk@42005 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
54a2c0dd1f
commit
5dab6b6e61
|
@ -635,6 +635,11 @@ window.wp = window.wp || {};
|
|||
selectionPosition = TinyMCEContentAreaTop + elementTop,
|
||||
visibleAreaHeight = windowHeight - ( edToolsHeight + toolbarHeight );
|
||||
|
||||
// There's no need to scroll if the selection is inside the visible area.
|
||||
if ( selectionPosition < visibleAreaHeight ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The minimum scroll height should be to the top of the editor, to offer a consistent
|
||||
* experience.
|
||||
|
@ -852,19 +857,16 @@ window.wp = window.wp || {};
|
|||
end = selection.end || selection.start;
|
||||
|
||||
if ( textArea.focus ) {
|
||||
// focus and scroll to the position
|
||||
// Wait for the Visual editor to be hidden, then focus and scroll to the position
|
||||
setTimeout( function() {
|
||||
textArea.setSelectionRange( start, end );
|
||||
if ( textArea.blur ) {
|
||||
// defocus before focusing
|
||||
textArea.blur();
|
||||
}
|
||||
textArea.focus();
|
||||
}, 100 );
|
||||
|
||||
textArea.focus();
|
||||
}
|
||||
|
||||
textArea.setSelectionRange( start, end );
|
||||
}
|
||||
|
||||
// Restore the selection when the editor is initialized. Needed when the Text editor is the default.
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-42173';
|
||||
$wp_version = '5.0-alpha-42175';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue