Skip to main content

Search and Top Navigation

#13167 new bug ()

Opened June 18, 2015 10:09AM UTC

Last modified July 26, 2016 03:04PM UTC

Datepicker: After calling refresh while calendar is open, calendar will not close

Reported by: timbofield Owned by: timbofield
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.11.3
Keywords: Cc:
Blocked by: Blocking:
Description

I'm calling refresh on hover, so that I can illustrate a range selected between two calendars. My beforeShowDay adds an appropriate class for cells between a start date and the hovered over date.

Seems to be a core bug here, after calling refresh ( in order to trigger beforeShowDay again ) the calendar won't close.

$('#ui-datepicker-div').on('mouseover.babdatepicker','.ui-datepicker-calendar td',function(e) {

   var hoverDateStr = ($(this).text()+'-'+ (inst.selectedMonth + 1) +'-'+inst.selectedYear);
   hoverDate = $.datepicker.parseDate('d-m-yy', hoverDateStr);
   self.endDatepicker.datepicker( "refresh" );
   e.stopPropagation(); //otherwise this will bubble up, and we don't need that
}

where self.endDatepicker is a datepicker widget. After the refresh call above the calendar will no longer close on click.

Attachments (0)
Change History (7)

Changed June 19, 2015 10:29AM UTC by scottgonzalez comment:1

component: ui.coreui.datepicker
owner: → timbofield
status: newpending

This doesn't sound like an appropriate use of beforeShowDay and refreshing. While it's a bug that you can't close the datepicker after doing this, I wouldn't count on the resolution of this ticketing being what you want. We may just make refresh() do nothing while open.

However, in the interest of pursuing this bug, can you please provide a reduced test case? The code provided above cannot by copy pasted into a page and have it work.

Changed June 19, 2015 11:32AM UTC by timbofield comment:2

status: pendingnew

Hi, Here is a fiddle that demonstrates the bug https://jsfiddle.net/j7xbq35y/1/

I've just noticed that this bug doesn't effect Firefox. I'm only seeing it in Chrome

beforeShowDay seems to be the only option available to achieve this via the API.

Changed June 19, 2015 11:43AM UTC by timbofield comment:3

''I also apologise for not spelling calendar correctly in the title! I can't work out how to change this now''

Changed June 19, 2015 01:22PM UTC by scottgonzalez comment:4

summary: After calling refresh while calender is open, calender will not close againDatepicker: After calling refresh while calendar is open, calendar will not close
I also apologise for not spelling calendar correctly in the title! I can't work out how to change this now

No problem. I've updated the title.

Changed June 19, 2015 01:25PM UTC by scottgonzalez comment:5

status: newpending

Can you please reduce the test case? A properly reduced test case would only be a few lines of code and would not create a new widget. We don't really expect you to be able to create a date range picker directly on top of a single datepicker.

Changed June 20, 2015 12:11AM UTC by timbofield comment:6

status: pendingnew

Ok, simplified fiddle here https://jsfiddle.net/j7xbq35y/2/

If the API provided a mouse over event for days ( providing date of hovered day ) in the Calendar this code would be much simpler. I imagine what I'm doing here is a fairly common use case.

Changed July 26, 2016 03:04PM UTC by pablo-pacheco comment:7

Same problem here. It works pretty well on firefox but not in Chrome. It's killing me! I don´t know what to do