-
Drew Willcoxon authored
Bug 1657918 - Don't add a heuristic result for empty searches in local search modes, and modify the view to allow it to stay open when empty. r=harry This excludes the heuristic for empty searches when in search mode. I haven't heard back from Verdi yet about excluding it for all searches in search mode. We can add that in a follow-up if necessary. Since we're now excluding the heuristic but we want the view to remain open, it's possible for the view to be empty while it's open. I had to make some changes to allow that to happen. There are three cases I want to call out: 1. When the search string is empty, the view shows top sites. If you then enter search mode and the resulting search doesn't return any results, we previously closed the view. This patch keeps it open. An example of this scenario is when you don't have any bookmarks and you click the bookmarks one-off. 2. When the urlbar isn't focused, it's in search mode, the input is empty, and the search didn't return any results, then focusing the urlbar didn't do anything previously. This patch auto-opens the view. 3. When the input contains a single char and it's in search mode, deleting the char previously closed the view if the empty search didn't return any results. This patch keeps the view open. When the view is empty, we also need to hide the one-offs' top border that usually separates them from the results. Otherwise there are two separator lines right next to each other, the one above the one-offs and the one at the bottom edge of the input. I don't think there's any CSS selector that will let us easily do this due to the DOM structure, so I added a new `noresults` attribute on the view for this. I had to call `context.searchString.trim()` to tell whether the search string is empty. Since we do that in a bunch of places, I added `context.trimmedSearchString`, and a lot of this patch is replacing those `trim` calls. Differential Revision: https://phabricator.services.mozilla.com/D86908
e2ab883d