Merge "Improve timing of sidebar opening and scrolling selection into view"

This commit is contained in:
jenkins-bot 2024-12-13 16:25:36 +00:00 committed by Gerrit Code Review
commit 0e643b39bf

View file

@ -17,6 +17,9 @@ ve.ui.EditCheckDialog = function VeUiEditCheckDialog( config ) {
// Parent constructor // Parent constructor
ve.ui.EditCheckDialog.super.call( this, config ); ve.ui.EditCheckDialog.super.call( this, config );
// Don't run a scroll if the previous animation is still running (which is jQuery 'fast' === 200ms)
this.scrollCurrentCheckIntoViewDebounced = ve.debounce( this.scrollCurrentCheckIntoView.bind( this ), 200, true );
// Pre-initialization // Pre-initialization
this.$element.addClass( 've-ui-editCheckDialog' ); this.$element.addClass( 've-ui-editCheckDialog' );
}; };
@ -138,7 +141,7 @@ ve.ui.EditCheckDialog.prototype.update = function () {
ve.ui.EditCheckDialog.prototype.position = function () { ve.ui.EditCheckDialog.prototype.position = function () {
this.drawHighlights(); this.drawHighlights();
this.scrollCurrentCheckIntoView(); this.scrollCurrentCheckIntoViewDebounced();
}; };
ve.ui.EditCheckDialog.prototype.drawHighlights = function () { ve.ui.EditCheckDialog.prototype.drawHighlights = function () {
@ -195,6 +198,10 @@ ve.ui.EditCheckDialog.prototype.setCurrentOffset = function ( offset ) {
this.updateSize(); this.updateSize();
if ( this.isOpening() ) {
return;
}
const surfaceView = this.surface.getView(); const surfaceView = this.surface.getView();
if ( this.currentChecks.length > 0 ) { if ( this.currentChecks.length > 0 ) {
// The currently-focused check gets a selection: // The currently-focused check gets a selection:
@ -206,7 +213,7 @@ ve.ui.EditCheckDialog.prototype.setCurrentOffset = function ( offset ) {
) )
); );
this.scrollCurrentCheckIntoView(); this.scrollCurrentCheckIntoViewDebounced();
} else { } else {
surfaceView.getSelectionManager().drawSelections( 'editCheckWarning', [] ); surfaceView.getSelectionManager().drawSelections( 'editCheckWarning', [] );
} }
@ -265,12 +272,11 @@ ve.ui.EditCheckDialog.prototype.getSetupProcess = function ( data ) {
ve.ui.EditCheckDialog.prototype.getReadyProcess = function ( data ) { ve.ui.EditCheckDialog.prototype.getReadyProcess = function ( data ) {
return ve.ui.EditCheckDialog.super.prototype.getReadyProcess.call( this, data ) return ve.ui.EditCheckDialog.super.prototype.getReadyProcess.call( this, data )
.next( () => { .next( () => {
// The end of the ready process triggers a reflow after an // Call update again after the dialog has transitioned open, as the first
// animation, so we need to get past that to avoid the content // call of update will not have drawn any selections.
// being immediately scrolled away
setTimeout( () => { setTimeout( () => {
this.scrollCurrentCheckIntoView(); this.update();
}, 500 ); }, OO.ui.theme.getDialogTransitionDuration() );
}, this ); }, this );
}; };