KES free asked 2 years ago

Expected behavior Hi. I need close datepicker when target date is choosen. But user should click button 'ok' to confirm the choise. The event 'dateChange' is unuseful for this task. It fires only when button 'ok' is clicked. I think the confirm button 'ok' should be optional. Thanks. Actual behavior

Resources (screenshots, code snippets etc.)

Michał Duszak staff answered 2 years ago

Untill this option is not introduced, you can imitate click on Ok button upon selecting the day. Here's an example of this workaround:

const datepickerEl = document.querySelector('.datepicker')
const datepicker = mdb.Datepicker.getInstance(datepickerEl)

document.body.addEventListener('open.mdb.datepicker', () => {
    setTimeout(() => {
        document.body.addEventListener('click', handleDatePickerCellClick)
    }, 0)


function handleDatePickerCellClick(e, okBtn) {
    const isCellTargeted ='datepicker-day-cell') ||'datepicker-day-cell')
  if(isCellTargeted) {

  setTimeout(() => {
        const okBtn = document.querySelector('.datepicker-ok-btn')
    document.body.removeEventListener('click', handleDatePickerCellClick)

Neo free answered 2 years ago

Also need auto-close option for datepicker plugin when a date was chosen by user, no need click the confirm button to close the popup.


Michał Duszak staff answered 2 years ago

Hello, thank you for your feedback. We will discuss it in the frontend team.

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 3.9.0
  • Device: computer
  • Browser: firefox
  • OS: linux
  • Provided sample code: No
  • Provided link: No