I am using Yii2 and bootstrap-datepicker v1.4.0 (with jQuery 3.6.0).
The main issue is that the datepicker is always opened at first page load, but only in Safari v16.5.
<?php Pjax::begin([
'timeout' => false
]);
$form = ActiveForm::begin([
'method' => 'get',
'options' => [
'class' =>'row mb-3',
'id' => 'form_filter'
]
]); ?>
<div class="col-12 col-md-3 offset-md-9 text-center">
<div class="row no-gutters">
<?= $form->field($searchModel, 'date_param', [
'options' => ['class' => 'input-group input-group-sm'],
'template' => '{input}<div class="input-group-append">
<span class="input-group-text bg-success text-white">
<i class="mdi mdi-calendar"></i>
</span>
</div>'
])->textInput([
'id'=>'date_param',
'placeholder' => 'Search by date..',
'autocomplete' => 'off'
])->label(false); ?>
</div>
</div>
<?php ActiveForm::end(); ?>
<div class="table-responsive">
<?= GridView::widget([
// .. the gridview contains select2 elements as filters
]) ?>
</div>
<?php Pjax::end(); ?>
Script to activate the datepicker is inside another JS file :
jQuery('#date_param').datepicker({
format: 'yyyy-mm-dd',
autoclose: true,
todayHighlight : false
});
There are 2 workarounds I am currently using :
I put another (dummy) text input element just right before the
date_param
filter.The gridview is included inside the ActiveForm so the
ActiveForm::end()
moved to the line just right before thePjax::end();
I am not sure if it helps, but we try on another page with the similar DOM and scripts, but the problem only happened on this particular page.
Thank you for any insight and feedback.