[wp-trac] [WordPress Trac] #42343: Customize: Themes search debounce is not debounced properly

WordPress Trac noreply at wordpress.org
Thu Oct 26 08:59:13 UTC 2017


#42343: Customize: Themes search debounce is not debounced properly
----------------------------+-------------------------
 Reporter:  afercia         |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  4.9
Component:  Customize       |    Version:  trunk
 Severity:  normal          |   Keywords:  needs-patch
  Focuses:  ui, javascript  |
----------------------------+-------------------------
 Debouncing a search, i.e. not triggering a search while users are still
 typing the search term, has a few advantages and WordPress is already
 using this pattern in a few places.

 The new Customize Theme search, especially for the .org themes, tries to
 debounce the search but as far as I see the current code fails to debounce
 properly. See https://core.trac.wordpress.org/browser/trunk/src/wp-
 admin/js/customize-controls.js?rev=42025&marks=1837-1846#L1837

 This code always calls `checkTerm()`, the first time is a debounced call
 and the second time is a direct call.

 To reproduce:

 - go in the customizer > change theme > WordPress.org themes
 - type something in the search field at a normal speed
 - observe the search gets triggered for any entered character

 The second call to `checkTerm()` runs always, for each entered character.
 Also, when typing slowly, `checkTerm()` is always called twice.

 To reproduce:
 - dump some `console.log()` inside `checkTerm()`
 - type 10 characters in the search field
 - observe your console dumping your `console.log()` 10 times + 1 time
 after 500ms
 or
 - enter 1 character and wait for at least 500ms
 - enter a second character
 - observe for each typed character, `checkTerm()` runs twice

 Observing the network panel in Chrome, multiple AJAX requests happen while
 typing. Seems to me `loadThemes()` helps a bit reducing the actual number
 of requests. However, requests should not be sent at all while typing.

 Ideally, nothing should happen while typing. The search should be
 triggered only after users have finished typing and 500ms have passed. As
 I see it, this is a bug in trunk and should be fixed for 4.9.

 Additionally, these kind of searches should be standardized across che
 admin. This was discussed a few times in the past, see for example
 https://core.trac.wordpress.org/ticket/37233#comment:21

 Ideally:
 - a search should be triggered after at least 2 chars have been entered
 (technically: 2 ASCII chars or one high UTF-8 char)
 - entering a space should not trigger a search

 Right now, entering a space in the search field triggers a search and a
 re-rendering of the whole themes list, which seems not so ideal to me even
 from an usability and user experience perspective.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42343>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list