Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #274 (closed defect: fixed)

Opened 14 years ago

Last modified 12 years ago

[PATCH] AutoCompleteField fixes + enhancements

Reported by: Claudio Martínez <koba@…> Owned by: anonymous
Priority: normal Milestone:
Component: TG Widgets Version:
Severity: normal Keywords:


The patch was done against revision 381. These changes have been tested on Opera 8.5, IE 6 and Firefox 1.5. I think the widget now is pretty enough to be used free of shame :)

  • Fixed a bug in the AutoCompleteField widget template, it wasn't including the attributes got via the attrs parameter on the Widget constructor. You need it to be able to specify the field size, for

example: field = AutoCompleteField(attrs=dict(size=50,maxlength=50))

  • Added a spinner image that "spins" while the AJAX request is in process (this was done pretty fast and needs some cleaning, specially on the template part, but it works). I borrowed the image from Mozilla FireFox?
  • The suggestions box is now aligned with the field
  • The suggestion highlighting is now optional and disabled by default, to enable it you have to return an option dictionary with highlight = True from the controller. For example: return dict(textItems=[p.Name for p in persons], options=dict(highlight=True))
  • A request will only be issued when the text actually changes and not when you press a key that doesn't alter the text (left arrow, right arrow, ctrl, etc)
  • When the field loses focus (you pressed tab or clicked somewhere else), the suggestion box is now cleared

For the future:

  • Add a timeout to the requests so if one of them doesn't get answered the spinner won't keep spinning forever
  • If responses get answered on a different order than they were sent (can happen a lot on connections with lots of packet loss AKA Wi-Fi) the suggestion box would get updated with the wrong results, I think this can be very annoying to the user. We should discard old requests
  • Add an option to disable the spinner (I didn't do this yet because I didn't figure how to implement it on the template)

Suggestions welcome -- Claudio Martínez


autocomplete.enh.diff Download (8.7 KB) - added by Claudio Martinez 14 years ago.
Diff against 381
spinnerstopped.png Download (545 bytes) - added by Claudio Martinez 14 years ago.
Stopped grayed out spinner
spinner.gif Download (2.0 KB) - added by Claudio Martinez 14 years ago.
Animated spinner

Change History

Changed 14 years ago by Claudio Martinez

Diff against 381

Changed 14 years ago by Claudio Martinez

Stopped grayed out spinner

Changed 14 years ago by Claudio Martinez

Animated spinner

comment:1 Changed 14 years ago by kevin

  • Status changed from new to closed
  • Resolution set to fixed

committed in [383]. Thanks!

comment:2 Changed 14 years ago by Claudio Martinez

  • Status changed from closed to reopened
  • Resolution fixed deleted

Looks like the spinner.gif and spinnerstopped.png commited on rev 383 are html pages.

Trac is really confusing regarding the image links. For example, this is a link to a html page containing the description of the item http://trac.turbogears.org/turbogears/attachment/ticket/274/spinnerstopped.png

And this is a link to the real image http://trac.turbogears.org/turbogears/attachment/ticket/274/spinnerstopped.png?format=raw

comment:3 Changed 14 years ago by anonymous

  • Status changed from reopened to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.