Merge lp:~deryck/lazr-js/stop-all-those-null-choice-edit-icons into lp:lazr-js

Proposed by Deryck Hodge
Status: Merged
Approved by: Deryck Hodge
Approved revision: 188
Merged at revision: 187
Proposed branch: lp:~deryck/lazr-js/stop-all-those-null-choice-edit-icons
Merge into: lp:lazr-js
Diff against target: 15 lines (+4/-1)
1 file modified
src-js/lazrjs/choiceedit/choiceedit.js (+4/-1)
To merge this branch: bzr merge lp:~deryck/lazr-js/stop-all-those-null-choice-edit-icons
Reviewer Review Type Date Requested Status
Paul Hummer (community) Approve
Review via email: mp+36494@code.launchpad.net

Commit message

Ensure NullChoiceSource widget does not continue to append remove icons with each click to open the widget.

Description of the change

This fixes bug 514190, which notes that every time you open and
close the milestone widget on a Launchpad bug page a bug, you get an
extra remove icon. This is because the widget didn't check to see
if the icon already existed before adding another. This branch
fixes that with a simple sniff of the string to see if we smell
"<img" or not.

I didn't add a test to this for a couple reasons.

1. It seems silly to test this to me
2. icons shouldn't be hardcoded, and therefore, not tested

There's much more work to make this null choice edit widget generic
and re-usable, but I wanted to fix the bug on Launchpad.

Thanks for the review!

Cheers,
deryck

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src-js/lazrjs/choiceedit/choiceedit.js'
2--- src-js/lazrjs/choiceedit/choiceedit.js 2010-04-13 13:02:44 +0000
3+++ src-js/lazrjs/choiceedit/choiceedit.js 2010-09-23 19:27:53 +0000
4@@ -634,7 +634,10 @@
5 });
6 }
7 for (var i = 0; i < v.length; i++) {
8- if (!Y.Lang.isValue(v[i].value)) {
9+ if (!Y.Lang.isValue(v[i].value) &&
10+ v[i].name.indexOf('<img') == -1) {
11+ // Only append the icon if the value for this item is
12+ // null, and the img tag is not already found.
13 v[i].name = [
14 '<img src="https://launchpad.net/@@/remove" ',
15 ' style="margin-right: 0.5em; border: none; ',

Subscribers

People subscribed via source and target branches