← Back to team overview

touch-packages team mailing list archive

[Bug 1513933] Re: Page.head.sections.selectedIndex does not reset when changing model

 

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
https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1511839
).

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to ubuntu-ui-toolkit in
Ubuntu.
https://bugs.launchpad.net/bugs/1513933

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

Status in Canonical System Image:
  Confirmed
Status in ubuntu-ui-toolkit package in Ubuntu:
  In Progress

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 .

To manage notifications about this bug go to:
https://bugs.launchpad.net/canonical-devices-system-image/+bug/1513933/+subscriptions


References