Search code examples
javascriptdatepickermaterialize

Materialize Date Picker automatically hide after opening problem on chrome


Materialize datepicker works fine in other browsers and old versions of Google Chrome but it doesn't work properly in new version of Google Chrome

enter image description here

<input type="date" class="datepicker">

JS

$('.datepicker').pickadate({

selectMonths: true, // Creates a dropdown to control month
selectYears: 15 // Creates a dropdown of 15 years to control year
});

Codepen Link for Datepicker


Solution

  • Solution for datepicker

    $('.datepicker').on('mousedown',function(event){
        event.preventDefault();
    })
    

    Solution for selectbox

    Delete this code in materialize.min.js

    $(this).trigger('open', ['focus']);
    or
    a(this).trigger("open",["focus"]);