on xenial help sign in
Prevent IndicatorItem removal while expanding

PanelBar uses some tricks to maintain the initial item's position while all items are expanding. For that to work, the initial item (and maybe every item, but I'm not sure) must not be removed by the ListView because PanelBar relies on the item's position for calculation. Ideally, because PanelItemRow expands the ListView to match its children, no item should fall out of its view. However, upon testing, the rightmost item can fall out of view and get destroyed under some circumstances. To solve this, ListView.delayRemove is bound to the transition's running state, so that it won't be removed while it's expanding (or retracting, but that probably doesn't matter). Fixes ubports/unity8#132.

commitb0fa7228e51cd70952df853e96a8a384f85d0afc authorRatchanan Srirattanamet <ratchanan@ubports.com> dateTue 18 Feb 2020, 21:56 (7 years ago) parentb8eb7f9
1 file changed+6
qml/Panel/Indicators/IndicatorItem.qml+6
qml/Panel/Indicators/IndicatorItem.qml+6
@@ -38,6 +38,11 @@ IndicatorDelegate {
3838
3939 implicitWidth: mainItems.width
4040
41+ // Prevent ListView from removing us from the view while expanding.
42+ // If we're the PanelBar's initial item, our removal will make it lose
43+ // track of us and cause its positioning to go wrong.
44+ ListView.delayRemove: stateTransition.running
45+
4146 MouseArea {
4247 readonly property int stepUp: 1
4348 readonly property int stepDown: -1
@@ -226,6 +231,7 @@ IndicatorDelegate {
226231
227232 transitions: [
228233 Transition {
234+ id: stateTransition
229235 PropertyAction { target: d; property: "useFallbackIcon" }
230236 AnchorAnimation {
231237 targets: [ mainItems, iconsItem, leftLabelItem, rightLabelItem ]