WordPress / revisions-extended

70 stars 10 forks source link

Prevent setting the date of a scheduled update to a time in the past #56

Open coreymckrill opened 3 years ago

coreymckrill commented 3 years ago

If you edit a scheduled update, and change the date to sometime in the past, the button changes to "Publish", but clicking it doesn't actually publish anything (which is good, since revisions should never be published themselves). Ideally, I think, the editor would just show an error message if you tried to set a date in the past.

bph commented 3 years ago

It does that now, see #65

StevenDufresne commented 3 years ago

This issue different from #65. It's referencing the time picker when you are specifically editing an update.

65 occurs when editing a specific post.

StevenDufresne commented 3 years ago

Do we want to use the default Gutenberg messaging system or try something in-line?

Also, I looked into controlling the minimum date but the Gutenberg control, which wraps a third party one that does support the feature, doesn't expose the minDate property.

Screenshot

coreymckrill commented 3 years ago

Is this screenshot the default GB messaging, or something custom? Default would be my first preference. The screenshot looks fine.

the Gutenberg control, which wraps a third party one that does support the feature, doesn't expose the minDate property.

D'oh. That might be worth filing an issue in the GB repo.

StevenDufresne commented 3 years ago

Is this screenshot the default GB messaging, or something custom? Default would be my first preference. The screenshot looks fine.

No, Gutenberg doesn't have a messaging system within the sidebar (75% sure :)). The default messaging is the one that appears at the top of the document that we have already used as the main update editing landmark.

coreymckrill commented 3 years ago

Here's a variation using WP Admin's notice and notice-error classes for the message container:

select-future

coreymckrill commented 3 years ago

94 partially addresses this issue because the datepicker in our custom sidebar connects to the "create update" button, and the button becomes disabled if a date in the past is picked. However, when editing a revision, it's still possible to pick a past date and then click the save button (which changes from "Update" to "Publish")

StevenDufresne commented 3 years ago

Noting: I looked into adding a PR for Gutenberg to accept a minDate since the underlying datepicker library does support it. However, Gutenberg imports a very specific version of the picker from that library that does not support it (https://github.com/airbnb/react-dates/blob/7a93b097af2e4f4ca8f8e6a329b213f49d70bd98/src/components/DayPickerSingleDateController.jsx#L37).

For now, we'll need to manage this internally.