Page.head.sections.selectedIndex does not reset when changing model

Bug #1513933 reported by Renato Araujo Oliveira Filho on 2015-11-06
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical System Image
Zoltan Balogh
ubuntu-ui-toolkit (Ubuntu RTM)
Tim Peeters

Bug Description

Changing Page.head.sections.model does not change the Page.head.sections.selectedIndex even when the model has different size.

I have a page that I need to update the ' Page.head.sections.model ' dynamically and after change the model or make it empty the Page.head.sections.selectedIndex still point to last value used.

I expect that to reset back to 0 if the model changes.

Check attached example .

Related branches

description: updated
description: updated
Zsombor Egri (zsombi) on 2015-11-11
Changed in ubuntu-ui-toolkit (Ubuntu):
assignee: nobody → Tim Peeters (tpeeters)
importance: Undecided → High
status: New → Confirmed
Bill Filler (bfiller) on 2015-11-23
Changed in canonical-devices-system-image:
assignee: nobody → Zoltan Balogh (bzoltan)
importance: Undecided → High
milestone: none → ww02-2016
Changed in canonical-devices-system-image:
status: New → Confirmed
Tim Peeters (tpeeters) on 2015-12-07
Changed in ubuntu-ui-toolkit (Ubuntu):
status: Confirmed → In Progress
Tim Peeters (tpeeters) wrote :

When the model is changed, some times the selectedIndex is no longer valid (too large) and must be changed.

However, the Sections does not know how the model was changed. Perhaps the model changed from ["one", "two", "three", "four"] to ["one", "two", "three"], with selectedIndex = 1 ("two"). It makes sense then that after changing the model, "two" is still selected. Since the app will know how/why the model changed, I think it is best for the app to set the new selectedIndex when the model changes.

To prevent a selectedIndex >= model.length, we can reset selectedIndex to, for example, 0 or -1 when the model changes. However, when setting the value to >=0, that will trigger the action (if any) associated with that index, which may be unwanted. The only way to prevent this is to always reset the selectedIndex to -1. In that case, no action is triggered, and the app may set sectionIndex to any desired value (which, in turn, will trigger an associated Action if there is one).

I attached an MR that does what I describe above. And it does this *only* if the model is changed after the Sections component was completed to prevent overriding a selectedIndex that was set by the app developer (which would cause a regression of this fix ).

Tim Peeters (tpeeters) wrote :

Note that this bug is also blocking the fix for

Tim Peeters (tpeeters) wrote :

I implemented the desired behavior in the attached MR. However, that conflicts with this bug:

Internally, the application header has a single Sections instance, and when the active Page changes, the PageHeadSections of that Page becomes active and updates the model of the Sections. That will reset the selectedIndex to 0. This is not a new problem with the new PageHeader, because each Page has its own PageHeader, but with the old PageHeadConfiguration and PageHeadSections the index must be reset to 0 with this behavior.

The solution is to use an old version of Sections in the (old) application header (configured with Page.head), and to use the new Sections with PageHeader. The new Sections (use PageHeader) always works as desired, but when using the Page.head.sections, the index is not reset to 0 when changing the model. So applications that change the model and require this behavior need to update the app to make use of the PageHeader (or implement a workaround where the app sets the new selectedIndex for Page.head.sections after the model is updated).

Changed in canonical-devices-system-image:
status: Confirmed → In Progress
Zoltan Balogh (bzoltan) on 2015-12-14
affects: ubuntu-ui-toolkit (Ubuntu) → ubuntu-ui-toolkit (Ubuntu RTM)
Zoltan Balogh (bzoltan) on 2015-12-16
Changed in ubuntu-ui-toolkit (Ubuntu RTM):
status: In Progress → Fix Committed
Changed in canonical-devices-system-image:
status: In Progress → Fix Committed
Łukasz Zemczak (sil2100) wrote :
Download full text (7.8 KiB)

This bug was fixed in the package ubuntu-ui-toolkit 1.3.1761+15.04.20151216.1-0ubuntu1 in


ubuntu-ui-toolkit (1.3.1761+15.04.20151216.1-0ubuntu1) vivid; urgency=medium

  [ Zoltán Balogh ]
  * Drop dependency on qtc plugin script and wait for the shell with a local

  [ Christian Dywan ]
  * needs to add subdirs to the libpath. Fixes: LP: #1524710.
  * Explicit click/ touch threshold beyond handler.
  * Enter/Return/Space should trigger() Button. Fixes: LP: #1523794.
  * Only set ppmm in SwipeArea if screen has valid dpi. Fixes: LP: #1525174.

  [ Tim Peeters ]
  * Implement header slot management for convergence:
    - Adapt the number of action slots to the width of the view.
    - When a new action appears, show a quick fade-in.
    - Reverse the order of the actions in the header.
    - Update icon width to 4GU. Fixes: LP: #1428757.
  * To prevent an invalid sectionIndex, reset the value of sectionIndex to -1
    when the model of Sections is changed. Fixes: LP: #1513933.

  [ Loïc Molinari ]
  * UbuntuShape - Cleaned up includes.

  [ Albert Astals Cid ]
  * Simplify logic for emitting draggingChanged/pressedChanged
    No need for a switch that considers the possible cases, just store the
    status before and check after
    Fixes an issue in which the SwipeArea pressedChanged signal was not emitted
    if switching directly from WaitingForTouch to Recognized.
  * Fix memory leak in SwipeArea
    SwipeAreaPrivate is not deleted directly so make it part of the qobject
    hierarchy so it's auto deleted on parent destruction.

  [ Zsombor Egri ]
  * Add reset functionality to Action.shortcut property. Fixes: LP: #1518420.
  * Add contentWidth and contentHeight to Dialog so foreground can be resized.
    Fixes: LP: #1249325.
  * Fixing ListItem.selected and ListItem.selectMode bugs.
    Fixes: LP: #1493880, LP: #1493882, LP: #1514928.
  * Add private implementations to ActionItem, AbstractButton, BottomEdgeHint
    and BottomEdge. Fixes: LP: #1524234
  * Close Popups.Dialog when Esc key is pressed. Fixes LP: #1523833
  * Invoke the overridden trigger() function for Action and ActionItem
    derivates. Fixes LP: #1524234
  * Fix BottomEdge assertion when the content is committed by clicking on the
    hint. Fixes LP: #1524407

  [ CI Train Bot ]
  * No-change rebuild.

ubuntu-ui-toolkit (1.3.1742+16.04.20151209-0ubuntu1) xenial; urgency=medium

  [ Zoltán Balogh ]
  * Enable building the UITK tests in any case.
  * Remove Q_Q(UCStyledItemBase) because of unused variable warning.
  * Resolve Trusty specific compiler issue not resolving QPointer data on
  * Use only the object name when selecting sections and labels in tests.

  [Zsombor Egri ]
  * Update BottomEdge with UI/UX agreed during the sprint. Fixes LP: #1368811.
  * BottomEdge component. Fixes LP: #1368811.
  * Remove build failure on Xenial caused by deprecated Qt functions.
  * Fix BottomEdgeHint consumes activeFocusOnPress handling. Fixes LP: #1517777
  * Migrate DirectionalDragArea from Unity8, named as SwipeArea. Original code
    (from lp...


Changed in ubuntu-ui-toolkit (Ubuntu RTM):
status: Fix Committed → Fix Released
Changed in canonical-devices-system-image:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments