Skip to content

DatePicker: Inline view wrong MetaData calculation and visible month/year after 4.4.0 update #8231

@dTodevDonatix

Description

@dTodevDonatix

Describe the bug

After the 4.4.0 release an issue started occurring when Datepicker is used with inline rendering. I have a page with 3 datepickers - 2 as input for start and end date and 1 as inline. They are interconnected through 3 state variables and watchers to keep them in sync.

I could also apply values to those state variables with outside methods and the components reacted properly until version 4.4.0 where it seems that the internal metadata calculation for the currentMonth, currentYear etc. happens before the rawValue(added in 4.4.0) is set. Therefore every update to the Datepicker calculates the previous state metadata because the updateCurrentMetaData call happens beforehand as per this commit b001959

I have prepared stackblitz with 4.4.1 which is current version. I personally spent time reading the entire refactoring that uses the new rawValue but I can't understand why is the call on line 631 in DatePicker.vue modelValue watcher here https://github.com/primefaces/primevue/blob/master/packages/primevue/src/datepicker/DatePicker.vue happening before the rawValue is set - shouldn't it be the opposite?

In the 4.4.1 stackblitz I added 2 lines that are commented out and if you uncomment them you will make it work. What these lines do is pretty much manually set the rawValue so the correct metadata is calculated, but that does not happen through the API and it's a bad pattern.

4.4.1
https://stackblitz.com/edit/7elhhhrr?file=src%2FApp.vue

Am I using the component incorrectly based on the latest updates or this is an actual bug?

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

No response

Reproducer

https://stackblitz.com/edit/7elhhhrr?file=src%2FApp.vue

Environment

N/A

Vue version

3.5.22

PrimeVue version

4.4.1

Node version

No response

Browser(s)

All of them

Steps to reproduce the behavior

Using the provided stackblitz:

  1. Open the link
  2. Use one of the inputs above the write in a date in format dd/mm/yyyy/ that is outside of the currently visible months
  3. The DatePicker with inline mode does not move it's visible months immediately
  4. Write in the same date or any other date
  5. The DatePicker now moves but takes in the previously entered value and in case it's not the same the visualized months are still incorrect

Not using the provided stackblitz:

  1. Run the latest PrimeVue version and just use DatePicker with inline vue setting it's internal range value to something random (not on mount and not from the UI, but afterwards programatically) and observe the DatePicker UI.

Expected behavior

The correct visible months and years in the inline DatePicker should be immediately visible on any value change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Needs TriageIssue will be reviewed by Core Team and a relevant label will be added as soon as possible

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions