Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.10.0 FF
-
None
Description
Summary
SearchField::currentIndex has some questionable behavor when SearchField is configured with a dynamic model (e.g. the model changes every time the user changes the text of the SearchField. This is how the SearchField is configured in the gallery). This makes SearchFields model quite dynamic/volatile, and consequently makes SearchField::currentIndex quite volatile in some cases (listed below):
Observations
Apply the patch 0001-Add-a-Label-that-shows-the-currentIndex-to-SearchFie.patch, compile and launch the gallery. Go to the SearchField page.
Set the text of the SearchField to "e"
=> it will show many entries in the popup (as expected). Move the mouse so that it hovers over the items in the popup. You will see that currentIndex changes. This is not how currentIndex works in ComboBox. This is how highlightedIndex works in ComboBox. Now click the last item in the list. You will see that currentIndex changes from 7 to 0. This is also expected, since when selecting "yellow", it will set it's text to "yellow", which will limit the model to one single item ("yellow").
However, it MIGHT also be interpreted as being is in conflict with the documentation of activated():
\qmlsignal void QtQuick.Controls::SearchField::activated(int index)
This signal is emitted when the item at \a index is activated by the user.
An item is activated when it is selected while the popup is open,
causing the popup to close (and \l currentIndex to change).
The \l currentIndex property is set to \a index.\sa currentIndex
First of all, it says that it will cause \l currentIndex to change. This is not the case, because \l currentIndex already changed to 7 when the mouse was hovered above the "yellow" (because currentIndex behaves like highlightedIndex).
Also, note that it says that \l currentIndex property it set to \a index. However, the observation is that \l currentIndex becomes 0.
Set the text of the SearchField to "e"
Click the entry with the text "red".
Clicking "red" will then set the text to "red", and the model should be filtered to only contain entries that contains "red": ("light red", "red" and "fred"). currentIndex should now be 2 (or 1). It is always 0, but this is a bug that we have identified (SearchField calls setCurrentIndex(0) when the popup is collapsed).
Summary
It is currently unclear for me the usefulness of currentIndex especially when SearchField::text is used to filter the model that is given to SearchField, then currentIndex becomes quite "volatile" (I suspect this to be a common usecase)
However, if the SearchField is not changing its model dynamically, currentIndex probably makes more sense (e.g. imagine a non-filtering search field in a web browser application)
Preliminary proposal
Add highlightedIndex. Let the mouse-hover-highlighting update the highlightedIndex, and do not change the currentIndex when hovering. currentIndex should only be updated when a highlighted item is activated (clicked or <Enter> pressed with keyboard).
Go through the documentation to review how currentIndex is documented to change, and verify that it is correct.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-137862 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
655212,5 | SearchField: Add highlightedIndex and fix ambiguous currentIndex behaviour | dev | qt/qtdeclarative | Status: NEW | 0 | 0 |