Modify ↓
Opened 7 years ago
Closed 7 years ago
#13296 closed defect (fixed)
spurious multiple space characters
Reported by: | Owned by: | Ryan J Ollos | |
---|---|---|---|
Priority: | normal | Component: | TracKeywordsPlugin |
Severity: | minor | Keywords: | |
Cc: | Trac Release: | 1.0 |
Description
It can happen that the TracKeywordsPlugin inserts multiple space characters when clicking multiple times on the same keyword.
I have tested this plugin (TracKeywordsPlugin 0.3dev-r0
/ revision r16858) with TRAC 1.0.4.
Reproduce
- click first keyword to insert
- click second keyword to insert
- click second keyword to removed
- repeat clicking on second keyword to insert / removed.
Each (repeated) remove operation leaves one extra space character in the keyword
field.
These spaces accumulate more and more.
Patch
I have modified the last line of the addTag
JS-function and improved the whitespace cleanup.
Previously it was only one Regex (el.value = newval.replace(/^\s+/, '');
).
Improved version:
function addTag(w) { var el = document.getElementById(field_id); var orig = el.value; var newval = orig.replace(new RegExp('\\b' + w + '\\b'), ''); var link = document.getElementById('add_' + w); if (orig != newval) { // remove tag. if(link) link.className = ''; } else { newval = orig + (orig ? ' ' : '') + w; if(link) link.className = 'sel'; } /*BUGFIX below this line: */ newval = newval.replace(/^\s+/, '');/*remove leading whitespace*/ newval = newval.replace(/\s+$/, '');/*remove trailing whitespace*/ newval = newval.replace(/\s{2,}/, ' ');/*remove multiple whitespace*/ el.value = newval; }
Thanks Clemens
Attachments (0)
Change History (4)
comment:1 Changed 7 years ago by
Reporter: | changed from anonymous to c.feige@… |
---|
comment:2 Changed 7 years ago by
Owner: | set to Ryan J Ollos |
---|---|
Status: | new → accepted |
comment:3 Changed 7 years ago by
Note: See
TracTickets for help on using
tickets.
Please consider providing a patch file in the future, to ease review (TracDev/SubmittingPatches).