Skip to content

Commit

Permalink
Revert merge #1891
Browse files Browse the repository at this point in the history
  • Loading branch information
acrobat committed Jan 22, 2017
1 parent 6de2c8e commit 4432f7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
14 changes: 5 additions & 9 deletions js/bootstrap-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,15 +806,11 @@
}
else if (this.dates.length){
// setting date by typing
if (typeof this.o.format === 'string') {
if ((String(this.element[0].value).length === String(this.o.format).length) && (String(oldDates) !== String(this.dates)))
this._trigger('changeDate');
this.element.change();
} else if (String(oldDates) !== String(this.dates)) {
this._trigger('changeDate');
this.element.change();
}
}
if (String(oldDates) !== String(this.dates) && fromArgs) {
this._trigger('changeDate');
this.element.change();
}
}
if (!this.dates.length && oldDates.length) {
this._trigger('clearDate');
this.element.change();
Expand Down
20 changes: 0 additions & 20 deletions tests/suites/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,23 +479,3 @@ test('Changing view mode triggers changeViewMode', function () {
equal(viewMode, 4);

});

test('Manually changing date should not trigger changeDate until we finish typing(it meets the required format)', function(){

var triggers = 0;
var expectedTriggers = 1;

this.input.on('changeDate', function(){
triggers++
});

this.input.focus();
this.input.val('04-03-20');
this.dp.update();
this.input.val('04-03-201');
this.dp.update();
this.input.val('04-03-2013');
this.dp.update();

equal(triggers, expectedTriggers);
});

9 comments on commit 4432f7a

@amucino
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will test this later today and see if it works.

@acrobat
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! If you have a working solution and the tests pass please open a new PR!

@amucino
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to find the code above in my datepicker.js but could not find it.
Is there a place where I can find an updated file ?
I am using version 1.3.21 I think the code above may be from a different version, if so which one is it and where can I download it?

@acrobat
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can find this state in the latest RC (1.7.0-RC1) or in the master branch. These are changes/fixes only applied to 1.7.0 and not backported to older versions

@amucino
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acrobat
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes indeed!

@amucino
Copy link

@amucino amucino commented on 4432f7a Jan 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One silly questions. I am new to Github so I am learning how this work, from the proposed code above I understand I should add the code in red on top of the code in green found in the original file?

If this is the case the fix did not work. I typed the first full date mm/dd/yyyy, then I started typing the end date and when I got to the year the last two digits of the start date were removed :(

@acrobat
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no silly questions here ;)

This is the revert commit so you should look at PR #1891 to see the original changes made to fix this issue. But the test are failing with the changes in the PR.

@amucino
Copy link

@amucino amucino commented on 4432f7a Jan 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. RC (1.7.0-RC1) Doesn't work. I am using the latest code in the main fork and that code doesn't actually check to make sure the second date is later than the first one and in fact by using the code in the main fork the rest of the scripts in my page stopped working (date format validation).

Is there a version of this script that is proven to work after 1.3 ? If so
Is there a way to simply disable reformatting the first date ?
I can add a separate piece of code to do this check on my own.

Please sign in to comment.