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:
parent
a8cb27ddd0
commit
c8556c166a
1 changed files with 5 additions and 9 deletions
|
|
@ -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);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue