[ui] GraphEditor: Search filtering fix

Fixed the issue where navigation arrows on the Filtering was allowing to set an index even when the search had null as the result.

Accepted signal on the Seach invokes the function rather than invoking the sigal for the button
This commit is contained in:
waaake 2024-11-30 20:14:13 +05:30
parent b0ed5e465e
commit 3a04ce668f

View file

@ -1096,32 +1096,23 @@ Item {
textField.onTextChanged: navigation.currentIndex = -1
onAccepted: {
nextArrow.clicked()
navigation.navigateForward()
}
}
MaterialToolButton {
text: MaterialIcons.arrow_left
padding: 0
enabled: graphSearchBar.text !== ""
onClicked: {
navigation.currentIndex--
if (navigation.currentIndex === -1)
navigation.currentIndex = filteredNodes.count - 1
navigation.nextItem()
}
visible: graphSearchBar.text !== ""
onClicked: navigation.navigateBackward()
}
MaterialToolButton {
id: nextArrow
text: MaterialIcons.arrow_right
padding: 0
enabled: graphSearchBar.text !== ""
onClicked: {
navigation.currentIndex++
if (navigation.currentIndex === filteredNodes.count)
navigation.currentIndex = 0
navigation.nextItem()
}
visible: graphSearchBar.text !== ""
onClicked: navigation.navigateForward()
}
Label {
@ -1147,6 +1138,32 @@ Item {
}
}
function navigateForward() {
/**
* Moves the navigation index forwards and focuses on the next node as per index.
*/
if (!filteredNodes.count)
return
navigation.currentIndex++
if (navigation.currentIndex === filteredNodes.count)
navigation.currentIndex = 0
navigation.nextItem()
}
function navigateBackward() {
/**
* Moves the navigation index backwards and focuses on the previous node as per index.
*/
if (!filteredNodes.count)
return
navigation.currentIndex--
if (navigation.currentIndex === -1)
navigation.currentIndex = filteredNodes.count - 1
navigation.nextItem()
}
function nextItem() {
// Compute bounding box
var node = nodeRepeater.itemAt(filteredNodes.itemAt(navigation.currentIndex).index_)