EditCheck: Don't scroll in mid-edit checks except on user interaction with EditCheck

Change-Id: Ic8268a87eb010ddac480f0375ad794dc2682e1f6
This commit is contained in:
Ed Sanders 2024-12-12 16:24:49 +00:00
parent 414e5d29ed
commit de84364ae8

View file

@ -36,6 +36,8 @@ ve.ui.EditCheckDialog.static.size = OO.ui.isMobile() ? 'full' : 'medium';
ve.ui.EditCheckDialog.static.framed = false; ve.ui.EditCheckDialog.static.framed = false;
ve.ui.EditCheckDialog.static.activeSurface = true;
// Invisible title for accessibility // Invisible title for accessibility
ve.ui.EditCheckDialog.static.title = OO.ui.deferMsg( 'editcheck-review-title' ); ve.ui.EditCheckDialog.static.title = OO.ui.deferMsg( 'editcheck-review-title' );
@ -103,7 +105,7 @@ ve.ui.EditCheckDialog.prototype.initialize = function () {
this.positionDebounced = ve.debounce( this.position.bind( this ), 100 ); this.positionDebounced = ve.debounce( this.position.bind( this ), 100 );
}; };
ve.ui.EditCheckDialog.prototype.update = function () { ve.ui.EditCheckDialog.prototype.update = function ( fromUserAction ) {
const surfaceView = this.surface.getView(); const surfaceView = this.surface.getView();
// We only regenerate the checks on-change during the edit. If we're in // We only regenerate the checks on-change during the edit. If we're in
// the proofreading step, no new checks should appear based on changes: // the proofreading step, no new checks should appear based on changes:
@ -137,12 +139,14 @@ ve.ui.EditCheckDialog.prototype.update = function () {
surfaceView.setReviewMode( true, highlightNodes ); surfaceView.setReviewMode( true, highlightNodes );
} }
this.setCurrentOffset( newOffset ); this.setCurrentOffset( newOffset, fromUserAction );
}; };
ve.ui.EditCheckDialog.prototype.position = function () { ve.ui.EditCheckDialog.prototype.position = function () {
this.drawHighlights(); this.drawHighlights();
this.scrollCurrentCheckIntoViewDebounced(); if ( this.reviewMode ) {
this.scrollCurrentCheckIntoViewDebounced();
}
}; };
ve.ui.EditCheckDialog.prototype.drawHighlights = function () { ve.ui.EditCheckDialog.prototype.drawHighlights = function () {
@ -179,8 +183,9 @@ ve.ui.EditCheckDialog.prototype.drawHighlights = function () {
* Set the offset of the current check, within the list of all checks * Set the offset of the current check, within the list of all checks
* *
* @param {number} offset * @param {number} offset
* @param {boolean} fromUserAction
*/ */
ve.ui.EditCheckDialog.prototype.setCurrentOffset = function ( offset ) { ve.ui.EditCheckDialog.prototype.setCurrentOffset = function ( offset, fromUserAction ) {
// TODO: work out how to tell the window to recalculate height here // TODO: work out how to tell the window to recalculate height here
this.currentOffset = Math.max( 0, offset ); this.currentOffset = Math.max( 0, offset );
@ -214,7 +219,9 @@ ve.ui.EditCheckDialog.prototype.setCurrentOffset = function ( offset ) {
) )
); );
this.scrollCurrentCheckIntoViewDebounced(); if ( fromUserAction || this.reviewMode ) {
this.scrollCurrentCheckIntoViewDebounced();
}
} else { } else {
surfaceView.getSelectionManager().drawSelections( 'editCheckWarning', [] ); surfaceView.getSelectionManager().drawSelections( 'editCheckWarning', [] );
} }
@ -332,7 +339,7 @@ ve.ui.EditCheckDialog.prototype.onAct = function ( widget, choice, actionChosen,
this.update(); this.update();
}, pause ); }, pause );
} else { } else {
this.updateDebounced(); this.updateDebounced( true );
} }
} ); } );
}; };
@ -347,7 +354,7 @@ ve.ui.EditCheckDialog.prototype.onAct = function ( widget, choice, actionChosen,
ve.ui.EditCheckDialog.prototype.onToggleCollapse = function ( check, index, collapsed ) { ve.ui.EditCheckDialog.prototype.onToggleCollapse = function ( check, index, collapsed ) {
if ( !collapsed ) { if ( !collapsed ) {
// expanded one // expanded one
this.setCurrentOffset( this.currentChecks.indexOf( check ) ); this.setCurrentOffset( this.currentChecks.indexOf( check ), true );
} }
}; };
@ -365,14 +372,14 @@ ve.ui.EditCheckDialog.prototype.onCloseButtonClick = function () {
* Handle click events from the next button * Handle click events from the next button
*/ */
ve.ui.EditCheckDialog.prototype.onNextButtonClick = function () { ve.ui.EditCheckDialog.prototype.onNextButtonClick = function () {
this.setCurrentOffset( this.currentOffset + 1 ); this.setCurrentOffset( this.currentOffset + 1, true );
}; };
/** /**
* Handle click events from the previous button * Handle click events from the previous button
*/ */
ve.ui.EditCheckDialog.prototype.onPreviousButtonClick = function () { ve.ui.EditCheckDialog.prototype.onPreviousButtonClick = function () {
this.setCurrentOffset( this.currentOffset - 1 ); this.setCurrentOffset( this.currentOffset - 1, true );
}; };
/* Registration */ /* Registration */