Fix datepicker showing up twice, and close datepicker when selecting a date