aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPorter Clevidence <116387727+porterclev@users.noreply.github.com>2024-08-05 10:30:53 -0700
committerGitHub <noreply@github.com>2024-08-05 19:30:53 +0200
commit02a6e6bcb004696b21324ef14c07374a56d7cd02 (patch)
tree74b31f0f8bee8eaf38416ac0b5cc9378925ce43b
parenta0c5b12e8291e40cf43c61844d50a5f7fdfe021a (diff)
downloadjquery-ui-02a6e6bcb004696b21324ef14c07374a56d7cd02.tar.gz
jquery-ui-02a6e6bcb004696b21324ef14c07374a56d7cd02.zip
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
-rw-r--r--tests/unit/datepicker/methods.js11
-rw-r--r--ui/widgets/datepicker.js1
2 files changed, 11 insertions, 1 deletions
diff --git a/tests/unit/datepicker/methods.js b/tests/unit/datepicker/methods.js
index 32d611748..ec83fb791 100644
--- a/tests/unit/datepicker/methods.js
+++ b/tests/unit/datepicker/methods.js
@@ -11,7 +11,7 @@ var beforeAfterEach = testHelper.beforeAfterEach;
QUnit.module( "datepicker: methods", beforeAfterEach() );
QUnit.test( "destroy", function( assert ) {
- assert.expect( 35 );
+ assert.expect( 39 );
var inl,
inp = testHelper.init( "#inp" ),
dp = $( "#ui-datepicker-div" );
@@ -21,6 +21,15 @@ QUnit.test( "destroy", function( assert ) {
assert.equal( dp.css( "display" ), "block", "Datepicker - visible" );
inp.datepicker( "hide" ).datepicker( "destroy" );
assert.ok( $.datepicker._curInst == null, "Datepicker - destroyed and cleared reference" );
+ assert.equal( dp.css( "display" ), "none", "Datepicker - absent" );
+
+ // Destroy without manual hiding (ensure datepicker is hidden after calling destroy)
+ inp = testHelper.init( "#inp" );
+ inp.datepicker( "show" );
+ assert.equal( dp.css( "display" ), "block", "Datepicker - visible" );
+ inp.datepicker( "destroy" );
+ assert.ok( $.datepicker._curInst == null, "Datepicker - destroyed and cleared reference" );
+ assert.equal( dp.css( "display" ), "none", "Datepicker - absent" );
inp = testHelper.init( "#inp" );
assert.ok( inp.is( ".hasDatepicker" ), "Default - marker class set" );
diff --git a/ui/widgets/datepicker.js b/ui/widgets/datepicker.js
index 605760572..323723b89 100644
--- a/ui/widgets/datepicker.js
+++ b/ui/widgets/datepicker.js
@@ -435,6 +435,7 @@ $.extend( Datepicker.prototype, {
$target.removeClass( this.markerClassName ).empty();
}
+ $.datepicker._hideDatepicker();
if ( datepicker_instActive === inst ) {
datepicker_instActive = null;
this._curInst = null;