mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-29 08:50:58 +01:00
Save, then restore scroll position in Chrome textareas on remarkup assist
Summary: Fixes T10396. Seems like this has been around for a while (references from 2011): http://stackoverflow.com/questions/4002312/chrome-resets-the-textarea-scroll-bar-scrolltop-when-focus-is-called https://bugs.chromium.org/p/chromium/issues/detail?id=75072 Commenting out this `focus()` seemed to fix the issue locally, at the cost of not focusing. Saving, focusing, then restoring seems to produce the correct behavior everywhere. Test Plan: - In Safari, Firefox and Chrome, typed a ton of text into a remarkup area (more than the height of the area, so it has a scrollbar). - Selected some text near the top. - Clicked "B" to bold the text. - Scroll position remained the same in all browsers (previously: in Chrome, it changed). Reviewers: chad Reviewed By: chad Maniphest Tasks: T10396 Differential Revision: https://secure.phabricator.com/D15313
This commit is contained in:
parent
50f910ce67
commit
7b1b146620
2 changed files with 15 additions and 8 deletions
|
@ -8,7 +8,7 @@
|
||||||
return array(
|
return array(
|
||||||
'names' => array(
|
'names' => array(
|
||||||
'core.pkg.css' => '7935f211',
|
'core.pkg.css' => '7935f211',
|
||||||
'core.pkg.js' => '298d5888',
|
'core.pkg.js' => '7d8faf57',
|
||||||
'darkconsole.pkg.js' => 'e7393ebb',
|
'darkconsole.pkg.js' => 'e7393ebb',
|
||||||
'differential.pkg.css' => '2de124c9',
|
'differential.pkg.css' => '2de124c9',
|
||||||
'differential.pkg.js' => 'd0cd0df6',
|
'differential.pkg.js' => 'd0cd0df6',
|
||||||
|
@ -462,7 +462,7 @@ return array(
|
||||||
'rsrc/js/core/Notification.js' => 'ccf1cbf8',
|
'rsrc/js/core/Notification.js' => 'ccf1cbf8',
|
||||||
'rsrc/js/core/Prefab.js' => 'e67df814',
|
'rsrc/js/core/Prefab.js' => 'e67df814',
|
||||||
'rsrc/js/core/ShapedRequest.js' => '7cbe244b',
|
'rsrc/js/core/ShapedRequest.js' => '7cbe244b',
|
||||||
'rsrc/js/core/TextAreaUtils.js' => '9e54692d',
|
'rsrc/js/core/TextAreaUtils.js' => '5813016a',
|
||||||
'rsrc/js/core/Title.js' => 'df5e11d2',
|
'rsrc/js/core/Title.js' => 'df5e11d2',
|
||||||
'rsrc/js/core/ToolTip.js' => '6323f942',
|
'rsrc/js/core/ToolTip.js' => '6323f942',
|
||||||
'rsrc/js/core/behavior-active-nav.js' => 'e379b58e',
|
'rsrc/js/core/behavior-active-nav.js' => 'e379b58e',
|
||||||
|
@ -775,7 +775,7 @@ return array(
|
||||||
'phabricator-slowvote-css' => 'da0afb1b',
|
'phabricator-slowvote-css' => 'da0afb1b',
|
||||||
'phabricator-source-code-view-css' => 'cbeef983',
|
'phabricator-source-code-view-css' => 'cbeef983',
|
||||||
'phabricator-standard-page-view' => 'e709f6d0',
|
'phabricator-standard-page-view' => 'e709f6d0',
|
||||||
'phabricator-textareautils' => '9e54692d',
|
'phabricator-textareautils' => '5813016a',
|
||||||
'phabricator-title' => 'df5e11d2',
|
'phabricator-title' => 'df5e11d2',
|
||||||
'phabricator-tooltip' => '6323f942',
|
'phabricator-tooltip' => '6323f942',
|
||||||
'phabricator-ui-example-css' => '528b19de',
|
'phabricator-ui-example-css' => '528b19de',
|
||||||
|
@ -1275,6 +1275,11 @@ return array(
|
||||||
'javelin-request',
|
'javelin-request',
|
||||||
'javelin-util',
|
'javelin-util',
|
||||||
),
|
),
|
||||||
|
'5813016a' => array(
|
||||||
|
'javelin-install',
|
||||||
|
'javelin-dom',
|
||||||
|
'javelin-vector',
|
||||||
|
),
|
||||||
'59a7976a' => array(
|
'59a7976a' => array(
|
||||||
'javelin-install',
|
'javelin-install',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
|
@ -1621,11 +1626,6 @@ return array(
|
||||||
'phabricator-phtize',
|
'phabricator-phtize',
|
||||||
'changeset-view-manager',
|
'changeset-view-manager',
|
||||||
),
|
),
|
||||||
'9e54692d' => array(
|
|
||||||
'javelin-install',
|
|
||||||
'javelin-dom',
|
|
||||||
'javelin-vector',
|
|
||||||
),
|
|
||||||
'9f36c42d' => array(
|
'9f36c42d' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
|
|
|
@ -33,7 +33,14 @@ JX.install('TextAreaUtils', {
|
||||||
|
|
||||||
setSelectionRange : function(area, start, end) {
|
setSelectionRange : function(area, start, end) {
|
||||||
if ('setSelectionRange' in area) {
|
if ('setSelectionRange' in area) {
|
||||||
|
|
||||||
|
// Chrome scrolls the textarea to the bottom as a side effect of
|
||||||
|
// calling focus(), so save the scroll position, focus, then restore
|
||||||
|
// the scroll position.
|
||||||
|
var scroll_top = area.scrollTop;
|
||||||
area.focus();
|
area.focus();
|
||||||
|
area.scrollTop = scroll_top;
|
||||||
|
|
||||||
area.setSelectionRange(start, end);
|
area.setSelectionRange(start, end);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue