Skip to content

Commit 7c53cf0

Browse files
committed
Remove the listener for input events.
We won't be needing this listender anymore since the bootstrap-datepicker offers an clearDate-event. We can just listen to that event instead of checking for an empty input ourselves. And instead of triggering the changeDate action with a null value we will trigger a clearDate action.
1 parent 0334d96 commit 7c53cf0

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

addon/components/datepicker-support.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ export default Ember.Mixin.create({
4848
self._didChangeDate(event);
4949
});
5050
}).
51-
on('input', function() {
52-
if (!self.$().val()) {
53-
self._applyDateValue(null);
54-
}
55-
}).
5651
on('focusout', function(event) {
5752
self.sendAction('focus-out', self, event);
5853
}).
@@ -83,10 +78,6 @@ export default Ember.Mixin.create({
8378
}
8479

8580
this.set('mustUpdateInput', false);
86-
this._applyDateValue(value);
87-
},
88-
89-
_applyDateValue: function(value) {
9081
this.set('value', value);
9182
this.sendAction('changeDate', value);
9283
},

tests/integration/components/bootstrap-datepicker-integration-test.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,10 @@
1-
import Ember from 'ember';
21
import hbs from 'htmlbars-inline-precompile';
32
import { moduleForComponent, test } from 'ember-qunit';
43

54
moduleForComponent('bootstrap-datepicker', 'BootstrapDatepickerComponent', {
65
integration: true
76
});
87

9-
test('resets date when input is cleared', function (assert) {
10-
assert.expect(2);
11-
12-
this.set('myDate', new Date());
13-
14-
this.render(hbs`
15-
{{bootstrap-datepicker value=myDate}}
16-
`);
17-
18-
var datepicker = this.$('input.ember-text-field').datepicker();
19-
20-
datepicker.val('');
21-
Ember.run(() => {
22-
datepicker.trigger('input');
23-
});
24-
25-
assert.equal(this.get('myDate'), null, 'value is reset');
26-
assert.equal(this.$('input.ember-text-field').datepicker('getDate'), null, 'datepicker is updated');
27-
});
28-
29-
test('triggers changeDate action when input field is cleared', function (assert) {
30-
assert.expect(1);
31-
32-
this.set('myDate', new Date());
33-
34-
var actionIsTriggered = false;
35-
this.on('myAction', () => {
36-
actionIsTriggered = true;
37-
});
38-
39-
this.render(hbs`
40-
{{bootstrap-datepicker value=myDate changeDate="myAction"}}
41-
`);
42-
43-
var datepicker = this.$('input.ember-text-field').datepicker();
44-
45-
datepicker.val('');
46-
Ember.run(() => {
47-
datepicker.trigger('input');
48-
});
49-
50-
assert.ok(actionIsTriggered, 'action is triggered');
51-
});
52-
538
test('triggers specified action on focusout event', function (assert) {
549
assert.expect(1);
5510

0 commit comments

Comments
 (0)