plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
452 stars 614 forks source link

Recurring dates keep switching back to wrong dates #5515

Open cihanandac opened 9 months ago

cihanandac commented 9 months ago

Describe the bug While creating an event, if set the dates to recur at certain days of every month, each time when the event is edited, the dates change to recurring in same day for every month.

To Reproduce Steps to reproduce the behavior:

  1. Create an Event page
  2. Click Recurrence
  3. Set Repeat to Monthly
  4. Set Repeat On to Second Monday
  5. Save it
  6. Click Edit the page
  7. Check the Recurrence again

Expected behavior I am trying to create an event with recurring dates; it needs to recur at second Monday every month. I can save it and it will appear fine on the event. But each time when I edit the event, the dates change to recurring in same day (11th in this case) for every month.

**Screenshots What I set: The second Monday

Screenshot 2023-12-11 at 10 28 17

What happens after editing: Day 11 of the Month

Screenshot 2023-12-11 at 10 28 45

https://github.com/plone/volto/assets/67173940/06910997-ae3c-414f-8bda-8e0ce220232a

**

Software:

stevepiercy commented 9 months ago

What happens if you select a Event Starts and Event Ends date for the event, then attempt to make it recurring?

Can you replicate the issue on https://demo.plone.org/ which has the latest versions?

I found that on the demo site, I was able to replicate your experience.

stevepiercy commented 9 months ago

There are definitely some UI issues and at least one bug. The modal dialog does not synch up with the sidebar.

Even when I first set Event Starts and Event Ends dates, a list of daily dates appears until I save the recurrence and the event.

https://github.com/plone/volto/assets/102112/bd423746-700e-4e01-82f9-0f1833c2e835

cihanandac commented 9 months ago

@stevepiercy thanks for you answer. I have tried setting the start and end dates before clicking the recurrence, but the result is the same. After your answer, i understand that I have jumped the conclusion early; It keeps the correct dates until I click edit and save the recurrence again.

But the Recurrence screen still doesn't sync with the correct dates.

In the screen recording that you shared, you also recreate this problem; At first the dates are : Dec 10, Jan 7, Feb 11, March 10, April 7, May 12 After you edit for the second time: Dec 10, Jan 10, Feb 10, March 10, April 10, May 10

stevepiercy commented 9 months ago

Yeah, after my first message, I tried a couple of things and was able to replicate it in the movie.

Additionally at 0:36, you can see a looooong list of all the dates between the start and end dates with an elided 73 more dates, which after saving in the modal dialog then changes to only the 10th of the month.

stevepiercy commented 9 months ago

See also https://github.com/plone/volto/issues/4906

raghavKasyap commented 9 months ago

I had gone through the codebase and I found that the edit form can be extracted out into its own component RecurrenceEditForm. This component handles the state of the edit form itself. The Edit Form Modal has a preview section which is generated based on the values of fields in the form. So the logic which coverts the form's state to rule options required for RRule (rrule package) which in-turn generates the rruleSet goes inside of the RecurrenceEditFormcomponent . And once the save is clicked this rruleSet is used to update the rruleSet of the RecurrenceWidget component. The other things that go inside of RecurrenceEditForm are exdates, rdates which also define the recurrence dates.

Below is a pictorial representation of the above explained refactor of the RecurrenceWidget component.

image

I had tried to implement this architecture and fine tuned the parsing from formValues to rrulesSet and rrulesSet to formValues and all the issues corresponding to the Recurrence Widget UI sync were eradicated.

Please provide your valuable suggestions on the probable improvements.

raghavKasyap commented 9 months ago

https://github.com/plone/volto/pull/5575 Hi I have raised a pull requests implementing the above architecture. It is not complete yet. I have provided the description on how one can use the new components for viewing the changes. I need help in writing down tests for these new components. Any help would be much appreciated. Thanks!!