Skip to content

Commit

Permalink
Ensure observable subscriptions trigger for emptySelectFirst, ensure …
Browse files Browse the repository at this point in the history
…before_nested_change and after_nested_change propagate on control change
  • Loading branch information
cloudcms committed Jul 25, 2019
1 parent 597e4aa commit bf9b0b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/js/ControlField.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,16 @@

// we use a timeout here because we want this to run AFTER control click handlers
setTimeout(function() {

// propagate up with "before_nested_change"
self.triggerWithPropagation("before_nested_change", e);

self.onChange.call(self, e);
self.triggerWithPropagation("change", e);

// propagate up with "after_nested_change"
self.triggerWithPropagation("after_nested_change", e);

}, 200);
});

Expand Down
6 changes: 6 additions & 0 deletions src/js/fields/list/ListField.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,19 @@
{
self.selectOptions[0].selected = true;
self.data = [self.selectOptions[0]];

self.updateObservable();
self.triggerUpdate();
}

// likewise, we auto-assign first pick if field required
if (self.data.length === 0 && self.isRequired() && self.selectOptions.length > 0)
{
self.selectOptions[0].selected = true;
self.data = [self.selectOptions[0]];

self.updateObservable();
self.triggerUpdate();
}

callback();
Expand Down

0 comments on commit bf9b0b9

Please sign in to comment.