Skip to content

Fix: Allow leading zeros in HowTo block time duration fields#22511

Merged
enricobattocchi merged 0 commit intoYoast:trunkfrom
param-chandarana:trunk
Aug 26, 2025
Merged

Fix: Allow leading zeros in HowTo block time duration fields#22511
enricobattocchi merged 0 commit intoYoast:trunkfrom
param-chandarana:trunk

Conversation

@param-chandarana
Copy link
Copy Markdown
Contributor

Context

Users reported that they cannot enter leading zeros (like "00" or "01") in HowTo block time duration fields. This prevents them from inputting valid time formats like "00:30" for 30 minutes, which is a common use case for recipe and tutorial timings.

Summary

This PR can be summarized in the following changelog entry:

  • Fixes a bug where users could not enter leading zeros in HowTo block time duration fields when specifying cooking or preparation times.

Suggested label: changelog: bugfix

Relevant technical choices:

  • Replaced regex-based leading zero removal with direct parseInt() parsing in the formatDuration() method
  • Maintains backward compatibility and all existing validation logic
  • Uses standard JavaScript parseInt(string, 10) which properly handles leading zeros while still converting to proper integers
  • No changes to the public API or existing functionality

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  1. Create a new post or page in WordPress admin
  2. Add a HowTo block to the content
  3. Click "Add total time" in the HowTo block
  4. Try to enter "00" in the hours field - it should now accept this input
  5. Try to enter "01" in the minutes field - it should now accept this input
  6. Try to enter "05" in any time field - it should now accept this input
  7. Verify that the time displays correctly in the frontend (e.g., "00:30" should show as "30 minutes")
  8. Verify that existing functionality still works (entering "10", "30", etc.)

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • HowTo structured data blocks (time duration input fields)
  • Time duration formatting and validation logic
  • Frontend display of HowTo block time information

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #12541

@enricobattocchi enricobattocchi merged commit dc970b4 into Yoast:trunk Aug 26, 2025
28 checks passed
@agnieszkaszuba agnieszkaszuba added this to the 25.9 milestone Aug 26, 2025
@agnieszkaszuba agnieszkaszuba added the changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog label Aug 26, 2025
@enricobattocchi enricobattocchi removed this from the 25.9 milestone Aug 27, 2025
@enricobattocchi
Copy link
Copy Markdown
Member

Hey @param-chandarana, not sure what happened but the PR looks merged while the change hasn't been applied. Can you re-open the PR?

@enricobattocchi enricobattocchi added this to the 25.9 milestone Aug 28, 2025
@marinakoleva marinakoleva removed this from the 25.9 milestone Sep 9, 2025
@leonidasmi leonidasmi added this to the 25.9 milestone Sep 9, 2025
@marinakoleva
Copy link
Copy Markdown
Contributor

Note: The changelog of this PR was not included in the changelog of Free 25.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog community-patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HH and MM fields in HowTo block do not allow 00

6 participants