Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monthSelectPlugin error on mobile view #219

Open
Ilahaka77 opened this issue Oct 17, 2023 · 1 comment
Open

monthSelectPlugin error on mobile view #219

Ilahaka77 opened this issue Oct 17, 2023 · 1 comment

Comments

@Ilahaka77
Copy link

Ilahaka77 commented Oct 17, 2023

as in the title, I got this error when trying to display my website on mobile.

this is my code:
`import { useRef, useState, useEffect } from 'react'
import FullCalendar from '@fullcalendar/react'
import dayGridPlugin from '@fullcalendar/daygrid'
import Flatpickr from 'react-flatpickr'
import monthSelectPlugin from 'flatpickr/dist/plugins/monthSelect/index'
import 'flatpickr/dist/plugins/monthSelect/style.css'
import { ChevronLeftIcon, ChevronRightIcon, PlusIcon } from '@heroicons/react/24/solid'
import dayjs from 'dayjs'

const Schedule = () => {

const flatpickrOptionn = {
    warp: true,
    plugins: [
        new monthSelectPlugin({
            shorthand: true,
            dateFormat: "F Y",
            altFormat: "F Y",
        })
    ]
}

const calendar = useRef()
const selectMonth = useRef()

const [month, setMonth] = useState(dayjs().format('MMMM YYYY'))

const handleMonthChange = (e) => {
    setMonth(dayjs(e).format('MMMM YYYY'))
    const api = calendar.current.getApi()
    api.gotoDate(dayjs(e).toISOString())
}

const handlePrevMonth = () => {
    const api = calendar.current.getApi()
    api.prev()
    setMonth(api.currentData.viewTitle)
}

const handleNextMonth = () => {
    const api = calendar.current.getApi()
    api.next()
    setMonth(api.currentData.viewTitle)
}

useEffect(() => {
    
}, [])

return(
    <>
        <div className="mb-3 w-full flex justify-between items-center">
            <div>
                <button className="btn btn-ghost" onClick={() => handlePrevMonth()}><ChevronLeftIcon className="w-6 h-6"/></button>
                <Flatpickr ref={selectMonth} options={flatpickrOptionn} className="text-3xl font-semibold w-64 text-center" value={month} onChange={handleMonthChange}/>
                <button className="btn btn-ghost" onClick={() => handleNextMonth()}><ChevronRightIcon className="w-6 h-6"/></button>
            </div>
            <div className="float-right">
                <button className="btn btn-success btn-sm text-white" onClick={() => showModal('create')}>
                    <PlusIcon className="w-3 h-3"/>
                    Create
                </button>
            </div>
        </div>
        <FullCalendar
            ref={calendar}
            plugins={[ dayGridPlugin ]}
            initialView="dayGridMonth"
            headerToolbar={false}
            selectable={true}
        />
    </>
)

}

export default Schedule`

this is error message i get:
image

@vyartym
Copy link

vyartym commented Oct 8, 2024

As a workaround this option can be used in flatpickrOptions to omit the error: https://flatpickr.js.org/mobile-support/

{
    disableMobile: "true"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants