WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.2k forks source link

Post Date Block - Reverts to the default format when the custom date/time format input field is cleared. #64602

Open CacheMeOwside opened 2 months ago

CacheMeOwside commented 2 months ago

Description

When I clear the custom date/time format input field in the Date block, the "Default format" setting gets toggled on automatically. Expected outcome: The input field should get cleared, and stay that way until I enter a custom date format.

Step-by-step reproduction instructions

  1. Add the Date block to any post/page/template
  2. Toggle the "Default format" off under Block settings.
  3. Choose "Custom" from "Choose a format" dropdown.
  4. Clear the pre-filled text from the format input field - either by selecting all and pressing delete or by deleting the characters one by one.
  5. When the input field is cleared, the "Default format" (from Step 2) gets toggled on.

I tried these steps in the following themes - Twenty Twenty-Four, Twenty Twenty-Three, and Twenty Twenty-Two - and was able to reproduce the issue in all three.

Screenshots, screen recording, code snippet

https://github.com/user-attachments/assets/b7083616-e60b-43d0-a0e1-a2fb05428ff3

Environment info

Please confirm that you have searched existing issues in the repo.

Please confirm that you have tested with all plugins deactivated except Gutenberg.

rohitmathur-7 commented 2 months ago

I have a fix ready for this on my local, But I am getting some error on committing my code. Will raise PR once that is fixed.