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

Calendar component fires onYearMonthDisplayChange on mount #538

Open
nobeltws opened this issue Aug 16, 2024 · 0 comments
Open

Calendar component fires onYearMonthDisplayChange on mount #538

nobeltws opened this issue Aug 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@nobeltws
Copy link

Component
Calendar

Describe the bug
The assigned callback function for onYearMonthDisplayChange is invoked when the Calendar component is mounted onto the DOM.

To Reproduce
Steps to reproduce the behavior:

  1. Render the Calendar component and provide a callback function to the prop onYearMonthDisplayChange
  2. Go to the browser to view the Calendar
  3. onYearMonthDisplayChange callback is invoked when Calendar component is mounted to the DOM even when there is no interaction to trigger the callback.

Expected behavior
onYearMonthDisplayChange should not be invoked when the Calendar component mounts. This callback should be invoked when the year or month of the calendar changes. (e.g. when clicking on the month selector, year selector or left right navigation buttons. These buttons can be found on the top left and top right of the Calendar component)

Screenshots
image

Additional context
You may do a simple replication to console.log something from the callback function to check on the issue.
Our current UI is to call an API to fetch the available dates when year or month changes. During the API fetch, we render a Loading component which unmounts the Calendar. Once the fetch is done, we mount the Calendar component back. In this scenario, we have an infinite loop to calling the API. API is called when the Calendar mounts, this triggers the Loading component to mount and Calendar to unmount, followed by the Calendar mounting again when the API is done fetching and triggering the API call again.

@nobeltws nobeltws added the bug Something isn't working label Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant