react-date-picker icon indicating copy to clipboard operation
react-date-picker copied to clipboard

How can I disable manual input date from keyboard? mentioned fix deprecated

Open workforbala opened this issue 2 years ago • 1 comments

Before you start - checklist

  • [X] I followed instructions in documentation written for my React-Date-Picker version
  • [X] I have checked if this bug is not already reported

Description

How can I disable manual input date from keyboard? I wan't to leave possibility use calendar UI only.

mentioned fix for this issue is deprecated not working on all the browser. https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-user-input

Steps to reproduce

try not to type keyboard in put on date picker

Expected behavior

keydown method so developer can disable user to enter.

Actual behavior

keydown method so developer can disable user to enter.

Additional information

No response

Environment

  • Browser (if applicable):
  • React-Date-Picker version:
  • React version:

workforbala avatar Jul 08 '22 11:07 workforbala

+1

carmelocatalfamo avatar Jul 15 '22 13:07 carmelocatalfamo

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

github-actions[bot] avatar Oct 17 '22 01:10 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Nov 07 '22 00:11 github-actions[bot]

Here is how i have done it

css

.react-date-picker__wrapper  .react-date-picker__inputGroup {
    pointer-events: none;
  }

js

const [openCalendar, setOpenCalendar] = useState(false);
    const calendarRef = useRef(null);

    useEffect(() => {
        const calendarComponent = document.querySelector('.react-date-picker__calendar')
        if (calendarComponent) {
            calendarRef.current = calendarComponent
        }
    }, []);

const toggleCalendar = (e) => {
        e?.preventDefault()
        if (e?.target && calendarRef.current.contains(e.target)) return
        setOpenCalendar(prev => !prev)
    }


return <div onClick={toggleCalendar}>
    <DatePicker
       // other props       
       isOpen={openCalendar}
       onCalendarClose={toggleCalendar}
    />
</div>

pitops avatar Apr 18 '24 10:04 pitops