1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

When loading a page with inlines, don't select/focus inlines which we immediately upgrade to "editing"

Summary:
Ref T13513. This is a bit clumsy, but the cleanest way to implement "isEditing" inlines today is to send them down as normal inlines and then simulate clicking "edit" on them.

When we do, don't focus the resulting editor: focusing it makes the page scroll around and highlight things in essentially random order as the editors load in.

Test Plan: Reloaded a page with some open editors, wasn't scrolled to them.

Maniphest Tasks: T13513

Differential Revision: https://secure.phabricator.com/D21217
This commit is contained in:
epriestley 2020-05-04 13:32:13 -07:00
parent fe501bd7f7
commit 3a76248071
2 changed files with 28 additions and 20 deletions

View file

@ -13,7 +13,7 @@ return array(
'core.pkg.js' => '632fb8f5',
'dark-console.pkg.js' => '187792c2',
'differential.pkg.css' => '2d70b7b9',
'differential.pkg.js' => '4d375e61',
'differential.pkg.js' => 'e6da9e6f',
'diffusion.pkg.css' => '42c75c37',
'diffusion.pkg.js' => 'a98c0bf7',
'maniphest.pkg.css' => '35995d6d',
@ -381,7 +381,7 @@ return array(
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8',
'rsrc/js/application/diff/DiffChangeset.js' => 'a49dc31e',
'rsrc/js/application/diff/DiffChangesetList.js' => '6992b85c',
'rsrc/js/application/diff/DiffInline.js' => 'a39fd98e',
'rsrc/js/application/diff/DiffInline.js' => 'e6b9b4f3',
'rsrc/js/application/diff/DiffPathView.js' => '8207abf9',
'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b',
'rsrc/js/application/diff/behavior-preview-link.js' => 'f51e9c17',
@ -778,7 +778,7 @@ return array(
'phabricator-dashboard-css' => '5a205b9d',
'phabricator-diff-changeset' => 'a49dc31e',
'phabricator-diff-changeset-list' => '6992b85c',
'phabricator-diff-inline' => 'a39fd98e',
'phabricator-diff-inline' => 'e6b9b4f3',
'phabricator-diff-path-view' => '8207abf9',
'phabricator-diff-tree-view' => '5d83623b',
'phabricator-drag-and-drop-file-upload' => '4370900d',
@ -1841,9 +1841,6 @@ return array(
'javelin-workflow',
'phabricator-draggable-list',
),
'a39fd98e' => array(
'javelin-dom',
),
'a4356cde' => array(
'javelin-install',
'javelin-dom',
@ -2135,6 +2132,9 @@ return array(
'javelin-dom',
'phabricator-draggable-list',
),
'e6b9b4f3' => array(
'javelin-dom',
),
'e8240b50' => array(
'javelin-behavior',
'javelin-stratcom',

View file

@ -43,6 +43,7 @@ JX.install('DiffInline', {
_undoText: null,
_draftRequest: null,
_skipFocus: false,
bindToRow: function(row) {
this._row = row;
@ -95,7 +96,7 @@ JX.install('DiffInline', {
// which we're currently editing. This flow is a little clumsy, but
// reasonable until some future change moves away from "send down
// the inline, then immediately click edit".
this.edit(this._originalText);
this.edit(this._originalText, true);
} else {
this.setInvisible(false);
}
@ -389,7 +390,9 @@ JX.install('DiffInline', {
return changeset.newInlineReply(this, text);
},
edit: function(text) {
edit: function(text, skip_focus) {
this._skipFocus = !!skip_focus;
// If you edit an inline ("A"), modify the text ("AB"), cancel, and then
// edit it again: discard the undo state ("AB"). Otherwise we end up
// with an open editor and an active "Undo" link, which is weird.
@ -607,19 +610,24 @@ JX.install('DiffInline', {
result_row = row;
}
// If the row has a textarea, focus it. This allows the user to start
// typing a comment immediately after a "new", "edit", or "reply"
// action.
var textareas = JX.DOM.scry(
row,
'textarea',
'differential-inline-comment-edit-textarea');
if (textareas.length) {
var area = textareas[0];
area.focus();
if (!this._skipFocus) {
// If the row has a textarea, focus it. This allows the user to start
// typing a comment immediately after a "new", "edit", or "reply"
// action.
var length = area.value.length;
JX.TextAreaUtils.setSelectionRange(area, length, length);
// (When simulating an "edit" on page load, we don't do this.)
var textareas = JX.DOM.scry(
row,
'textarea',
'differential-inline-comment-edit-textarea');
if (textareas.length) {
var area = textareas[0];
area.focus();
var length = area.value.length;
JX.TextAreaUtils.setSelectionRange(area, length, length);
}
}
row = next_row;