From 74bffc5d0d272ae7482fdeea2062337e88ffedf2 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Mon, 18 Jul 2022 15:55:51 +0200 Subject: [PATCH] Fix sidebar losing focus when unchecking params with space 1. Before, removePages() was calling setPage() with null. This makes sense for removed top-level parts because these are really removed from both sides of the dialog. Template parameters are never removed. Only unchecked (and removed from the right side of the dialog, but this is not what this code is about). When I navigate a parameter list and uncheck a parameter I need the focus and highlighting to stay. 2. We have a dedicated method when a parameter is unchecked. This can check if the removed parameter is also the selected one (called "set" in this code) and can reset this state. Without losing the highlighting or anything else. Bug: T312213 Change-Id: Ibb717ca49cae805617ebee196937c79daa72f1c1 --- .../ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js | 6 ++---- .../ve.ui.MWTransclusionOutlineParameterSelectWidget.js | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js b/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js index 6e2abe0cc6..6cc5178843 100644 --- a/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js +++ b/modules/ve-mw/ui/layouts/ve.ui.MWTwoPaneTransclusionDialogLayout.js @@ -307,10 +307,8 @@ ve.ui.MWTwoPaneTransclusionDialogLayout.prototype.removePages = function ( pages } ); this.stackLayout.removeItems( pagesToRemove ); - if ( isCurrentPageRemoved ) { - this.setPage( isCurrentParameter ? null : - nextSelectionCandidate || prevSelectionCandidate - ); + if ( isCurrentPageRemoved && !isCurrentParameter ) { + this.setPage( nextSelectionCandidate || prevSelectionCandidate ); } }; diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js index acce5eeaeb..f44980a44d 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js @@ -148,6 +148,12 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.markParameterAsUnused var item = paramName ? this.findItemFromData( paramName ) : null; if ( item ) { item.setSelected( false ); + paramName = paramName || null; + // An unused parameter can't be the active (set) one; it doesn't exist in the content pane + if ( this.itemSet === paramName ) { + this.itemSet = null; + item.setParameter( false ); + } } };