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

Editor: Incorrect save button label when toggling dates to schedule a post #60281

Open
Mamaduka opened this issue Mar 28, 2024 · 4 comments · May be fixed by #68331
Open

Editor: Incorrect save button label when toggling dates to schedule a post #60281

Mamaduka opened this issue Mar 28, 2024 · 4 comments · May be fixed by #68331
Assignees
Labels
[Feature] Document Settings Document settings experience [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@Mamaduka
Copy link
Member

I noticed a strange behavior of the "Now" button. It resets the time to my machine's time instead of the timezone set by WP, which can lead to strange scheduling behavior.

Example:

  1. Open a draft post and switch the publishing date to the future.
  2. The save button changes the label to "Schedule."
  3. Switch the date back and the save button label will be restored to "Publish."
  4. Click on "Now" and repeat the same steps.
  5. Notice that the label isn't reverted to "Publish."
  6. Click "Now" again and the label is reverted, even though the time =< current time.

I'm not 100% sure what the intended behavior should be here, but initially, I thought it was a bug caused by the update and had to re-test it on the trunk.

Screencast

CleanShot.2024-03-28.at.12.35.54.mp4

Originally posted by @Mamaduka in #60163 (review)

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Feature] Document Settings Document settings experience labels Mar 28, 2024
@tyxla
Copy link
Member

tyxla commented Mar 28, 2024

As also mentioned in the initial comment, this could be related to #3036.

@annezazu annezazu added this to Polish Apr 2, 2024
@annezazu annezazu moved this to Needs development in Polish Apr 2, 2024
@Mayank-Tripathi32
Copy link
Contributor

In the publish-date-time-picker component, there is an issue where clicking the "Now" button returns null, which creates an inconsistency with the DatePickerComponent. This causes the datepicker to incorrectly set dates in GMT format.
Current implementation:

	<InspectorPopoverHeader
				title={ __( 'Publish' ) }
				actions={
					showPopoverHeaderActions
						? [
								{
									label: __( 'Now' ),
									onClick: () => onChange?.( null ),
								},
						  ]
						: undefined
				}
				onClose={ onClose }
			/>

The proposed fix addresses this by passing the current datetime instead:

	const handleNowClick = () => {
          // Both TimePicker and DateTimePicker expect full ISO datetime string without timezone
          const now = new Date().toISOString().slice(0, 19);
          onChange?.(now);
    };

This solution resolves the intermittent datetime parsing issues that were occurring when the datepicker processed updates.

I will be opening up a PR for review

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Dec 26, 2024
@t-hamano
Copy link
Contributor

t-hamano commented Jan 8, 2025

The proposed fix addresses this by passing the current datetime instead:

I don't have a deep understanding of the background of this issue, but I have one concern if we adopt this approach. For example:

  • A writer presses the "Now" button at 9:00. The internal publish date will be updated at 9:00.
  • The writer starts writing an article. Time passes and the writer finishes writing the article at 9:30.
  • The writer presses the "Publish" button.

In this case, the writer would expect the article to be published at 9:30. But won't the actual publish date be the time the Now button was pressed, i.e. 9:00?

If so, this doesn't seem to be the expected behavior.

@Mayank-Tripathi32
Copy link
Contributor

The proposed fix addresses this by passing the current datetime instead:

I don't have a deep understanding of the background of this issue, but I have one concern if we adopt this approach. For example:

  • A writer presses the "Now" button at 9:00. The internal publish date will be updated at 9:00.
  • The writer starts writing an article. Time passes and the writer finishes writing the article at 9:30.
  • The writer presses the "Publish" button.

In this case, the writer would expect the article to be published at 9:30. But won't the actual publish date be the time the Now button was pressed, i.e. 9:00?

If so, this doesn't seem to be the expected behavior.

That does seem to be an issue. I agree that it should set the date-time to match the actual time of publishing. I'll explore alternative solutions to address this properly. Thanks for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Document Settings Document settings experience [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
Status: Needs development
Development

Successfully merging a pull request may close this issue.

4 participants