Opened 8 years ago

Last modified 7 years ago

#13167 new bug

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.

Change History (7)

comment:1 Changed 8 years ago by Scott González

Component: ui.coreui.datepicker
Owner: set to 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.

comment:2 Changed 8 years ago by timbofield

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.

comment:3 Changed 8 years ago by timbofield

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

comment:4 Changed 8 years ago by Scott González

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.

comment:5 Changed 8 years ago by Scott González

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.

comment:6 Changed 8 years ago by timbofield

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.

comment:7 Changed 7 years ago by pablo-pacheco

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

Note: See TracTickets for help on using tickets.