Be able to disable flatpickr input

See original GitHub issue

We should be able to prevent toggling of flatpickr when disabled prop is passed

https://github.com/chmln/flatpickr/releases/tag/v1.7.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14

github_iconTop GitHub Comments

4reactions
YoussefZidancommented, Apr 4, 2021

I used this solution and worked with me

const AppDatePicker = ({ onChange, placeholder, value, disabled }) => {
  const inputRef = useRef();
  useEffect(() => {
    inputRef.current.flatpickr.altInput.disabled = disabled;
  }, [disabled]);

  return (
    <Flatpickr
      ref={inputRef}
      style={{ marginTop: "18px" }}
      placeholder={placeholder}
      readOnly={false}
      value={value}
      className="form-control m-0"
      options={{ altInput: true, altFormat: "F j, Y", dateFormat: "Y-m-d", mode: "range" }}
      onChange={onChange}
    />
  );
};
1reaction
RahulReddy75commented, Nov 1, 2017

So, I fixed it by setting the dateFormat prop to the desired output format and disabling altInput prop. @jacobmischka Thanks for the input.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Options - Flatpickr
Config Option Type Default altFormat String "F j, Y" altInput Boolean false altInputClass String ""
Read more >
How to use enable and disable properties together in flatpickr ...
You can't use disable along with enable but here's how you can achieve disable weekends functionality but using onDayCreate.
Read more >
Flatpickr: disabling field bug - CodePen
Disabling a field when altInput = true doesn't disable flatpickr...
Read more >
flatpickr - lightweight datetimepicker & calendar - UNPKG
Allows the user to enter a date directly input the input field. By default, direct entry is disabled. clickOpens, boolean, true, Clicking on...
Read more >
[flatpickr] Input widget gets disable. when ... - OutSystems
When ever FlatPickr widgets are linked to the input widget, input widget gets disabled and calendar is also not visible. Unable to use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found