Skip to content

Commit

Permalink
Don't reuse click handler in enter selection, set on update
Browse files Browse the repository at this point in the history
(closes #3638)
  • Loading branch information
bhousel committed Dec 8, 2016
1 parent 1912251 commit a3de353
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions modules/ui/fields/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function uiFieldCheck(field) {
options = field.strings && field.strings.options,
values = [],
texts = [],
box = d3.select(null),
input = d3.select(null),
text = d3.select(null),
label = d3.select(null),
entity, value;
Expand Down Expand Up @@ -52,25 +52,28 @@ export function uiFieldCheck(field) {
.append('label')
.attr('class', 'preset-input-wrap');

enter.append('input')
enter
.append('input')
.property('indeterminate', field.type === 'check')
.attr('type', 'checkbox')
.attr('id', 'preset-input-' + field.id)
.on('click', function() {
var t = {};
t[field.key] = values[(values.indexOf(value) + 1) % values.length];
dispatch.call('change', this, t);
d3.event.stopPropagation();
});
.attr('id', 'preset-input-' + field.id);

enter.append('span')
enter
.append('span')
.text(texts[0])
.attr('class', 'value');

label = label.merge(enter);

box = label.selectAll('input');
input = label.selectAll('input');
text = label.selectAll('span.value');

input
.on('click', function() {
var t = {};
t[field.key] = values[(values.indexOf(value) + 1) % values.length];
dispatch.call('change', this, t);
d3.event.stopPropagation();
});
};


Expand All @@ -83,15 +86,15 @@ export function uiFieldCheck(field) {

check.tags = function(tags) {
value = tags[field.key];
box.property('indeterminate', field.type === 'check' && !value);
box.property('checked', value === 'yes');
input.property('indeterminate', field.type === 'check' && !value);
input.property('checked', value === 'yes');
text.text(texts[values.indexOf(value)]);
label.classed('set', !!value);
};


check.focus = function() {
box.node().focus();
input.node().focus();
};

return utilRebind(check, dispatch, 'on');
Expand Down

0 comments on commit a3de353

Please sign in to comment.