Skip to content

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

Merged
leonidasmi merged 0 commit intoYoast:trunkfrom
param-chandarana:trunk
Sep 11, 2025
Merged

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

Conversation

@param-chandarana
Copy link
Copy Markdown
Contributor

@param-chandarana param-chandarana commented Sep 10, 2025

Fixes #12541

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 HowTo block time duration fields would not accept leading zeros like "00" or "01".

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.

@leonidasmi leonidasmi merged commit e91ff95 into Yoast:trunk Sep 11, 2025
25 of 26 checks passed
@marinakoleva marinakoleva added this to the 25.9 milestone Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HH and MM fields in HowTo block do not allow 00

4 participants