Skip to content

Commit

Permalink
Fix first entry is not selected when a search is performed (keepassxr…
Browse files Browse the repository at this point in the history
  • Loading branch information
Colfenor committed Sep 25, 2023
1 parent 6b67f58 commit cd7a53a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/gui/entry/EntryView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,12 @@ void EntryView::displaySearch(const QList<Entry*>& entries)
m_model->setEntries(entries);
header()->showSection(EntryModel::ParentGroup);

setFirstEntryActive();

// Reset sort column to 'Group', overrides DatabaseWidgetStateSync
m_sortModel->sort(EntryModel::ParentGroup, Qt::AscendingOrder);
sortByColumn(EntryModel::ParentGroup, Qt::AscendingOrder);

setFirstEntryActive();
m_inSearchMode = true;
}

Expand Down
7 changes: 7 additions & 0 deletions tests/gui/TestGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,13 @@ void TestGui::testSearch()
QCOMPARE(groupView->currentGroup(), m_db->rootGroup());
QVERIFY(!m_dbWidget->isSearchActive());

// check if first entry is selected after search
QTest::keyClicks(searchTextEdit, "some");
QTRY_VERIFY(m_dbWidget->isSearchActive());
QTRY_COMPARE(entryView->selectedEntries().length(), 1);
QModelIndex index_current = entryView->indexFromEntry(entryView->currentEntry());
QTRY_COMPARE(index_current.row(), 0);

// Try to edit the first entry from the search view
// Refocus back to search edit
QTest::mouseClick(searchTextEdit, Qt::LeftButton);
Expand Down

0 comments on commit cd7a53a

Please sign in to comment.