Debounce Search Input
Pamac --version
Pamac 10.4.2-1 - libpamac 11.3.1-1
Variant in use
GUI
Distribution
Manjaro
Desktop environment
XFCE
What's not working
There is a noticable delay and momentary UI freeze when typing entries into the search box.
How to reproduce?
- Click the search icon
- Begin typing a search term into the search entry
- After the 2nd character of the search term is entered the UI freezes
- Continue typing and no characters will appear until the search completes
- If you use the same search term again during the same session the freeze does not happen
- If you use a different search term the same freeze will happen
- If you close and reopen the pamac-manager gui the same freeze will happen again
More information (optional)
Proposed Solution
Within resources/manager_window.ui use the search-changed signal to make the on_search_entry_changed callback instead of the changed signal. the search-changed signal is already "debounced" so it will wait for 150ms after the last keypress before initiating the search. This is a better user experience IMHO.
diff --git a/resources/manager_window.ui b/resources/manager_window.ui
index a1ce8f7..1028c07 100644
--- a/resources/manager_window.ui
+++ b/resources/manager_window.ui
@@ -53,7 +53,7 @@
<property name="halign">center</property>
<property name="max-width-chars">30</property>
<property name="placeholder-text" translatable="yes">Search</property>
- <signal name="changed" handler="on_search_entry_changed" swapped="no"/>
+ <signal name="search-changed" handler="on_search_entry_changed" swapped="no"/>
<signal name="activate" handler="on_search_entry_activated" swapped="no"/>
</object>
</child>