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

Issue where time won't change from 12:00 on first attempt #2342

Closed
Beckhem1998 opened this issue Nov 28, 2020 · 2 comments
Closed

Issue where time won't change from 12:00 on first attempt #2342

Beckhem1998 opened this issue Nov 28, 2020 · 2 comments
Assignees

Comments

@Beckhem1998
Copy link

The first time the flatpickr loads if you type a time then press enter, then it just resets to 12:00 :/

https://jsfiddle.net/x3nr725c/

  • flatpickr version used: 4.6.6
  • Browser name and version: Chrome | Version 86.0.4240.198 (Official Build) (x86_64)
  • OS and version: MacOS | Catalina V10.15.6
@chmln chmln self-assigned this Dec 3, 2020
@jelaniwoods
Copy link

I'm also experiencing this. From what I can tell, this still occurs with flatpickr versions 4.6.7 and 4.6.8 as well.
The latest version that appears to not have this problem seems to be 4.6.3. Here's a fiddle: https://jsfiddle.net/fme42zhu/

However, still using version 4.6.3, setting noCalendar to false causes the issue to happen again.

@jelaniwoods
Copy link

jelaniwoods commented Dec 22, 2020

I found a sort of ugly work around by modifying the updateTime function.

This is what I did:

        /**
         * The handler for all events targeting the time inputs
         */
        function updateTime(e) {
            // starting my edit
            if (self.selectedDates.length === 0 && self.hourElement.value !== undefined) {
                var defaultDate = self.config.minDate !== undefined
                    ? new Date(self.config.minDate.getTime())
                    : new Date();
                defaultDate.setHours(self.hourElement.value, self.minuteElement.value, 0, 0);
                self.setDate(defaultDate, false);
            }
            // ending my edit
            else if (self.selectedDates.length === 0) {
                var defaultDate = self.config.minDate !== undefined
                    ? new Date(self.config.minDate.getTime())
                    : new Date();
                var _a = getDefaultHours(), hours = _a.hours, minutes = _a.minutes, seconds = _a.seconds;
                defaultDate.setHours(hours, minutes, seconds, 0);
                self.setDate(defaultDate, false);
            }
            if (e !== undefined && e.type !== "blur") {
                timeWrapper(e);
            }
            var prevValue = self._input.value;
            setHoursFromInputs();
            updateValue();
            if (self._input.value !== prevValue) {
                self._debouncedChange();
            }
        }

Here's a fiddle https://jsfiddle.net/fme42zhu/1/

chmln added a commit that referenced this issue Dec 25, 2020
@chmln chmln closed this as completed in 479418a Dec 25, 2020
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

3 participants