question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calendar minDate is mutating input value

See original GitHub issue

Bug Report

Hi, I am porting Fomantic Calendar to a Vue component and just noticed a bug. Setting minDate(initially or after initialization) to a date that is later than the input value, it is mutating the input value as well.

Steps to reproduce

  1. set minDate to today
  2. set the value to a day that is before than minDate (initially)

Expected result

If the initial value is 1 august 2020, and minDate is 1 september 2020, input should show 1 august 2020, not 1 september 2020 which is minDate. It is misleading to show minDate inside input as the input is showing another date than the calendar value holds.

Actual result

Calendar is setting minDate as input value

Testcase

https://codepen.io/onelly/pen/YzqEPKd

Screenshot

Image

Version

2.8.3

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lubber-decommented, Sep 7, 2020

@elibolonur Yes, understood 🙂 . I just wanted to point out, that a change has to be done properly and might has more impact than it sounds.

1reaction
elibolonurcommented, Sep 7, 2020

@lubber-de Regarding to your message before; if we assume that a form field “always” will be filled I agree, by design, it makes sense. But if the form field may not be changed but is there as for the presentation, and if the user wants to update the date, then the minimum selectable date should be restricted only, not update the presenting currentValue. That is the scenario, and of course there is a validation layer both in frontend and backend.

And there is another side of it, porting it to vue and keeping all calendar setting properties in sync within vue component lifecycle/state and jQuery state. Suddenly calendar mutates the current value that leads us to an inconsistent vue/fomantic calendar component, which also is an anti pattern. Now, is it possible to accomplish what we are trying to do somehow inside the porting part? For sure yes, with a couple of “hacky” lines of code.

I mean, I understand that it is an issue to disable it and change the workflow. Keeping the current behaviour but giving an option to disable that minDate or maxDate is mutating the currentValue would make it easier, as this is going to be a common case with any modern JS framework where they have their own state management and trying to port fomantic calendar. Or maybe an event like onAutoAdjust to hook to the event or know when it is adjusting to prevent that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

in daterangepicker how can i set minDate Dynamically?
I want to set minDate Dynamically to end date input based on start date. In short, I want to prevent a user from...
Read more >
Populating Missing Dates with Complete and Fill Functions in ...
What this is going to do is to populate rows for all the combination of Date and Product column values. The Date values...
Read more >
airDatepicker: Air Date Picker Input in shinyWidgets - Rdrr.io
By default value is taken from current localization, but if it passed here then it will have higher priority. minDate. The minimum allowed...
Read more >
set minDate and maxDate using semantic-ui-calender-Vue.js
startTime.calendar({ type: 'time', minDate: minDate, maxDate: maxDate, onChange(date ... How can I set and get the value of an input component using Vue.js?...
Read more >
Vue Calendar Component - PrimeFaces
To disable entering dates manually, set manualInput to false and to restrict selectable dates with the minDate and maxDate options. <Calendar v-model="value" : ......
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