bootstrap-datepicker icon indicating copy to clipboard operation
bootstrap-datepicker copied to clipboard

Do not modify viewDate when some methods are called

Open bielfrontera opened this issue 10 years ago • 7 comments

setStartDate, setEndDate, setDaysOfWeekDisabled, setDaysOfWeekHighlighted and setDatesDisabled methods call update to repaint the component.

This causes a troublesome modification of viewDate, and therefore a possible unnecessary change of the displayed month. A new control variable has been added and now, viewDate is not modified when the methods above are called.

bielfrontera avatar Oct 27 '15 15:10 bielfrontera

I detected this issue when I was trying to modify the list disabled dates after changeMonth event is fired.

I call a service that provides the list of available dates for each month, and when I try to modify the calendar with this information (after changing the month), the widget returns to the previous month.

bielfrontera avatar Oct 27 '15 15:10 bielfrontera

I'm not fan of this change actually, feel more like a fix in order to avoid the issue, rather fixing it really. I'll look into this issue (if you can link a fiddle it would make my life easier), a fix might be to simply initiate viewDate outside of update, or maybe the initiation is bad.

Azaret avatar Oct 27 '15 16:10 Azaret

Hi, here you have a fiddle: http://jsfiddle.net/bielfrontera/grea506a/ My first approach was to avoid calling the update method and call fill method instead. It works for me, but there were two tests that failed, because they expect that date and viewDate are between startDate and endDate after calling setStartDate or setEndDate.

bielfrontera avatar Oct 27 '15 23:10 bielfrontera

@bielfrontera Can you rebase the PR against the current master?

acrobat avatar Apr 13 '17 11:04 acrobat

@vsn4ik @Azaret do you guys see any problems with this change at it could be merged together with #2054

acrobat avatar Apr 13 '17 11:04 acrobat

Hi @acrobat, I've rebased the PR! Hope it can be merged! :)

bielfrontera avatar Apr 18 '17 10:04 bielfrontera

@acrobat you can merge please ? i need it

guillaumeNeveux avatar Sep 28 '20 14:09 guillaumeNeveux