Bug Tracker

Modify

Ticket #2404 (closed bug: fixed)

Opened 5 years ago

Last modified 15 months ago

[autocomplete] space does not work as separator for multiple:true

Reported by: ayman Owned by: joern
Priority: major Milestone:
Component: plugin Version:
Keywords: autocomplete, multiple, multipleSeparator Cc:
Blocking: Blocked by:

Description

This is ticket is for the autocomplete plugin at:  http://dev.jquery.com/browser/trunk/plugins/autocomplete

When enabling the multiple option and setting the multipleSeparator option to a single space, autocomplete does not work anymore. This setup is quite common for tagging fields, in which you enter multiple tags separated by spaces.

I found the cause of the problem to be the following snippet:

function trimWords(value) {
 if ( !value ) {
   return [""];
 }
 var words = value.split( $.trim( options.multipleSeparator ) );
 var result = [];
 // ...
}

Calling $.trim on options.multipleSeparator removes the space and breaks the functionality of the plugin. This can be fixed by removing the call to $.trim on options.multipleSeparator.

I'm attaching a patch for this.

Thank you.

Attachments

autocomplete.patch Download (514 bytes) - added by ayman 5 years ago.
autocomplete-testcase.html Download (930 bytes) - added by ayman 5 years ago.
Test case

Change History

Changed 5 years ago by ayman

comment:1 Changed 5 years ago by joern

  • need changed from Review to Test Case
  • Owner set to joern
  • Summary changed from autocomplete plugin does not work with space as a separator to [autocomplete] space does not work as separator for multiple:true
  • Version 1.2.3 deleted
  • Milestone 1.2.4 deleted

Changed 5 years ago by ayman

Test case

comment:2 Changed 5 years ago by ayman

I've attached a test case as requested. Please put jquery.autocomplete.js and its dependencies in the same directory as the HTML file.

To see the bug, type in "java" in the text field and press space, and then type "p" and select "python" from the suggestions. The contents of the field will become "j a v a python" instead of "java python".

If you apply the patch, the problem will disappear.

comment:3 Changed 5 years ago by ayman

[ping]

Any updates? Is there anything else I need to do?

Thanks.

comment:4 Changed 5 years ago by DanSwitzer2

I've added this patch to the source code.

comment:5 Changed 5 years ago by scott.gonzal

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

Fixed in [4862]. Thanks Dan!

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.