Skip to content

Commit 02a6e6b

Browse files
authored
Datepicker: Hide the UI on destroy
When the datepicker UI is shown and then destroyed programmatically: ```js $( "#datepicker" ).datepicker( "destroy" ); ``` hide the datepicker UI without the need for an explicit user action. Previously, in 1.12 the UI would not disappear immediately but only after the first `mousedown`. In later 1.13 versions, the UI would not disappear at all. Fixes gh-2178 Closes gh-2268
1 parent a0c5b12 commit 02a6e6b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

tests/unit/datepicker/methods.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var beforeAfterEach = testHelper.beforeAfterEach;
1111
QUnit.module( "datepicker: methods", beforeAfterEach() );
1212

1313
QUnit.test( "destroy", function( assert ) {
14-
assert.expect( 35 );
14+
assert.expect( 39 );
1515
var inl,
1616
inp = testHelper.init( "#inp" ),
1717
dp = $( "#ui-datepicker-div" );
@@ -21,6 +21,15 @@ QUnit.test( "destroy", function( assert ) {
2121
assert.equal( dp.css( "display" ), "block", "Datepicker - visible" );
2222
inp.datepicker( "hide" ).datepicker( "destroy" );
2323
assert.ok( $.datepicker._curInst == null, "Datepicker - destroyed and cleared reference" );
24+
assert.equal( dp.css( "display" ), "none", "Datepicker - absent" );
25+
26+
// Destroy without manual hiding (ensure datepicker is hidden after calling destroy)
27+
inp = testHelper.init( "#inp" );
28+
inp.datepicker( "show" );
29+
assert.equal( dp.css( "display" ), "block", "Datepicker - visible" );
30+
inp.datepicker( "destroy" );
31+
assert.ok( $.datepicker._curInst == null, "Datepicker - destroyed and cleared reference" );
32+
assert.equal( dp.css( "display" ), "none", "Datepicker - absent" );
2433

2534
inp = testHelper.init( "#inp" );
2635
assert.ok( inp.is( ".hasDatepicker" ), "Default - marker class set" );

ui/widgets/datepicker.js

+1
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ $.extend( Datepicker.prototype, {
435435
$target.removeClass( this.markerClassName ).empty();
436436
}
437437

438+
$.datepicker._hideDatepicker();
438439
if ( datepicker_instActive === inst ) {
439440
datepicker_instActive = null;
440441
this._curInst = null;

0 commit comments

Comments
 (0)