UI/Qt: Prevent autocomplete highlight flicker while typing

While typing in the location bar, intermediate autocomplete updates
caused the highlighted suggestion to flicker.

These updates trigger on each keystroke and lead to unnecessary
selection changes.

Skip intermediate popup updates while it is visible and rely on final
results to update both suggestions and selection atomically.
This commit is contained in:
Christian Frey 2026-06-03 11:01:39 +02:00 committed by Andreas Kling
parent a8cb27ddd0
commit c8556c166a

View file

@ -255,16 +255,12 @@ LocationEdit::LocationEdit(QWidget* parent)
m_autocomplete->on_query_complete = [this](auto suggestions, WebView::AutocompleteResultKind result_kind) {
int selected_row = apply_inline_autocomplete(suggestions);
if (result_kind == WebView::AutocompleteResultKind::Intermediate && m_autocomplete->is_visible()) {
if (auto selected = m_autocomplete->selected_suggestion(); selected.has_value()) {
for (auto const& suggestion : suggestions) {
if (suggestion.text == *selected)
return;
}
}
m_autocomplete->clear_selection();
// Do not update the popup while results are still changing.
// Intermediate updates are triggered on every keystroke and would
// cause visible flicker in the suggestion list.
// Only final results are used to refresh the UI.
if (result_kind == WebView::AutocompleteResultKind::Intermediate && m_autocomplete->is_visible())
return;
}
m_autocomplete->show_with_suggestions(AK::move(suggestions), selected_row);
};