Posted by Thox on June 13, 2005 at 6:07pm
12 followers
| Project: | Drupal core |
| Version: | 7.x-dev |
| Component: | theme system |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Frando |
| Status: | needs work |
Issue Summary
I'd like the autocomplete matches to be underlined (or styled in some way) so that users can see which part of the strings returned was actually matched. See Screenshot.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| autocomplete_8.patch | 1.39 KB | Ignored: Check issue status. | None | None |
Comments
#1
Using bold instead of underline is much more effective. See screenshot or my usual autocomplete demo page.
New patch attached.
#2
Very nice feedback. On your demo page, I like the icon in the text field that indicates active "matching."
One small bug (it seems). Typing "c" alone gets me a list of matches, but the last (bottom) entry has a piece of javascript appended to it with a line through it.
Using Firefox 1.04 on Windows 2000.
Similar bug, but with several lines of javascript fragments in the match box, appears using MSIE 6 on Windows 2000.
#3
+1 on the idea, but wouldn't it be better to have the highlighting be done in a themable function on the server side?
For one thing, it makes it more flexible. But also, the displayed values can contain HTML, so there might be conflicts with HTML tags in there if you do a blind search and replace on the client-side. Think icons/thumbnails, Google Suggest-style popularity counts/indicators, etc.
If bloating the ajax data is a concern, then perhaps the default themable should use
<strong>instead of.#4
...instead of
<span class="match">.By the way Chris, the animated icon is called the throbber and it is part of core.
#5
Steven, originally I used an underline, then I used bold. Is it right to use
<strong>if the style might be completely different?I'm hoping to get the server side to use even less bandwidth. In the future, I'd like to remove the drupal_implode_matches function and get the folksonomy field working based on client-side code. This would remove duplicate data on the vast majority of autocomplete callbacks.
A suggestion was made in #drupal that the delay should be adjustable (either at coding time or with a simple admin control). The other suggestion, which appeals more to me, is to get the javascript to run a timer and adjust the suggestions delay based on the response time of the requests.
#6
Typically, bandwidth isn't the problem. The problem is the fact we have to load the entire core to handle a single request. That is, CPU cycles is the problem, not bandwidth. Personally, I'm in favor of keeping the Javascript code simple.
#7
ok, the patch bingo oracle can be cryptic: Why did I get a patch that has both CSS and JS?
Anyway: Thox' second patch didn't apply anymore, I've rerolled it and attach it.
The discussion has strayed a bit from the original issue, but I think that a server based solution (eg a themable function) is to be preferred.
#8
oops, part of the patch went mia. Seeting to "needs work" as i 'd really prefer a themable function.
#9
Yeah... the autocomplete separates displayed HTML from the autocomplete value, so you can just pass each match through a theme_autocomplete_highlight() or something which does a simple preg_replace by default.
#10
Very very nice feature. I rerolled both changes into one patch. Ready to be committed, if you ask me.
#11
Looks nice to me, lets commit it.
#12
-1 as this breaks HTML-formatted matches. Highlighting needs to happen on the server-side.
#13
+1 to this feature. Moving to 6.x-dev queue.
#14
Is there a 5.0 patch?
Thanks!
#15
No, there is no 5.0 patch. Please leave this in the 6.x-dev queue, as this is a new feature, and won't be going into the Drupal 5 branch.
#16
Nothing will happen to this patch unless someone changes it so the highlighting happens in the menu callback, not in the JavaScript. We cannot tell HTML from text in the JSON strings, and the server might want to do more advanced highlighting anyway.
#17
trying to fix markup.
#18
So,
here's a patch for drupal HEAD that introduces a new theme function theme_autocomplete_highlight. All core autocompletes are altered to use the highlight theme function (user select, tag select, profile field values and profile field groups).
Works great and is a valuable usability enhancment, IMO.
#19
You should use preg_quote to escape the check_plained input.
#20
Right. Patch rerolled.
#21
#22
Features have been frozen for a long time now. I'd like to see this in D7 though!
Moving to theme system, as we decided to go for a server based solution.
#23
Patch doesn't apply anymore.
#24
+1. Anyone up for re-rolling a patch? @Dries: can it still make it into D7?