Skip to content

Loading…

Don't trim typed input so that user's typing is not disrupted #35

Merged
merged 1 commit into from

2 participants

@skwp

If the user types 'foo ' with a space, and the ajax call comes back
successfully, it replaces the 'foo ' with 'foo' (trimmed).

This causes inconsistent user experience as the user may have simply
paused while typing a space, and the space is then removed, mangling
his input. Note that this fix simply avoids trimming the user's visual
input, while still sending a trimmed value to the server.

Danny Olson & Yan Pritzker Don't trim typed input so that user's typing is not disrupted
If the user types 'foo ' with a space, and the ajax call comes back
successfully, it replaces the 'foo ' with 'foo' (trimmed).

This causes inconsistent user experience as the user may have simply
paused while typing a space, and the space is then removed, mangling
his input. Note that this fix simply avoids trimming the user's visual
input, while still sending a trimmed value to the server.
ee277c7
@meltingice meltingice merged commit ee277c7 into meltingice:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 12, 2012
  1. Don't trim typed input so that user's typing is not disrupted

    Danny Olson & Yan Pritzker committed
    If the user types 'foo ' with a space, and the ajax call comes back
    successfully, it replaces the 'foo ' with 'foo' (trimmed).
    
    This causes inconsistent user experience as the user may have simply
    paused while typing a space, and the space is then removed, mangling
    his input. Note that this fix simply avoids trimming the user's visual
    input, while still sending a trimmed value to the server.
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/ajax-chosen.coffee
View
3 src/ajax-chosen.coffee
@@ -29,6 +29,7 @@ do ($ = jQuery) ->
# into the input form that chosen has created
# Retrieve the current value of the input form
+ untrimmed_val = $(@).attr('value')
val = $.trim $(@).attr('value')
# Depending on how much text the user has typed, let them know
@@ -107,7 +108,7 @@ do ($ = jQuery) ->
# call trigger above. Often, this can be very annoying (and can make some
# searches impossible), so we add the value the user was typing back into
# the input field.
- field.attr('value', val)
+ field.attr('value', untrimmed_val)
# Because non-ajax Chosen isn't constantly re-building results, when it
# DOES rebuild results (during liszt:updated above, it clears the input
Something went wrong with that request. Please try again.