Skip to content

Prevented Countdown block breakage when editing as HTML - #3131

Merged
pirate-bot merged 4 commits into
developmentfrom
bugfix/3127
Oct 23, 2026
Merged

pirate-bot merged 4 commits into
developmentfrom
bugfix/3127

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

Closes #3127

Summary

Fixed Countdown block invalidation after editing its HTML by restoring the generated markup and validating it with validateBlock(). Preserved wrapper edits, including data-date, while regenerating labels, digits, and separators to match the block's saved output. Retained HTML editing support instead of disabling supports.html, preserving the behavior introduced in #3072.


Checklist before the final review

  • Included E2E or unit tests for the changes in this PR.
  • Visual elements are not affected by independent changes.
  • It is at least compatible with the minimum WordPress version.
  • It loads additional script in frontend only if it is required.
  • Does not impact the Core Web Vitals.
  • In case of deprecation, old blocks are safely migrated.
  • It is usable in Widgets and FSE.
  • Copy/Paste is working if the attributes are modified.
  • PR is following the best practices

@pirate-bot

pirate-bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Diff

Package Old Size New Size Diff
Animations 178.33 KB 178.33 KB 0 B (0.00%)
Blocks 1.65 MB 1.65 MB 500 B (0.03%)
CSS 7.83 KB 7.83 KB 0 B (0.00%)
Dashboard 172.49 KB 172.49 KB 0 B (0.00%)
Onboarding 68.14 KB 68.14 KB 0 B (0.00%)
Export Import 4.73 KB 4.73 KB 0 B (0.00%)
Pro 439.85 KB 439.85 KB 0 B (0.00%)

@pirate-bot

pirate-bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Plugin build for b0f548f is ready 🛎️!

@pirate-bot

pirate-bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

E2E Tests

Playwright Test Status: See serial and parallel matrix jobs

Performance Results serverResponse: {"q25":315.06,"q50":333.82,"q75":343.52,"cnt":10}, firstPaint: {"q25":1201.51,"q50":1236.35,"q75":1350.05,"cnt":10}, domContentLoaded: {"q25":3271.34,"q50":3281.46,"q75":3332.67,"cnt":10}, loaded: {"q25":3274.47,"q50":3284.55,"q75":3335.92,"cnt":10}, firstContentfulPaint: {"q25":1671.93,"q50":2161.11,"q75":2456.43,"cnt":10}, firstBlock: {"q25":15685.99,"q50":15783.23,"q75":15901.61,"cnt":10}, type: {"q25":26.05,"q50":29.35,"q75":34.17,"cnt":10}, typeWithoutInspector: {"q25":22.95,"q50":26.03,"q75":29.3,"cnt":10}, typeWithTopToolbar: {"q25":31.2,"q50":35.33,"q75":38.69,"cnt":10}, typeContainer: {"q25":15.48,"q50":16.18,"q75":17.39,"cnt":10}, focus: {"q25":125.7,"q50":134.55,"q75":138.76,"cnt":10}, inserterOpen: {"q25":40.66,"q50":41.32,"q75":43.23,"cnt":10}, inserterSearch: {"q25":26.75,"q50":28.77,"q75":29.75,"cnt":10}, inserterHover: {"q25":5.32,"q50":5.62,"q75":5.93,"cnt":20}, loadPatterns: {"q25":1676.78,"q50":1686.71,"q75":1860.81,"cnt":10}, listViewOpen: {"q25":198.25,"q50":205.51,"q75":219.2,"cnt":10}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A successful repair leaves stale cached input, causing a repeated identical HTML edit to leave the Countdown invalid.

1 open issue
What changed in this PR

This PR addresses Countdown invalidation after HTML editing by restoring generated content while preserving wrapper edits, including data-date, and keeping HTML mode available.

Changes:

  • Restore generated Countdown markup from saved output.
  • Validate repaired markup before updating the block.
  • Add unit and end-to-end coverage for label edits and combined date-and-label edits.
File Description
src/​blocks/​test/​unit/​html-edit-attributes.test.js Tests generated markup restoration and wrapper preservation.
src/​blocks/​test/​e2e/​blocks/​block-html-mode.spec.js Adds Countdown label and combined-edit scenarios.
src/​blocks/​plugins/​html-edit/​index.js Integrates markup restoration into validated block repair.
src/​blocks/​plugins/​html-edit/​attributes.js Adds the Countdown selector and markup restoration helper.

Review effort: Balanced

return;
}

dispatch( 'core/block-editor' ).updateBlock( block.clientId, {

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes requested

A repaired Countdown label edit becomes invalid again when the same textarea text is committed again. Reset the repair guard after a successful repair.

  • src/blocks/test/e2e/blocks/block-html-mode.spec.js:8 — comments The comment on EDITABLE says the edited markup "is read back into" comment attributes. The new generated label cases do not work that way. Their label edit is discarded and restored from save, and expected keeps the old date. Reword the comment to cover both cases, for example: "Blocks whose edited markup is read back into attributes, or restored from save for generated markup, so the block stays valid."
Validation details
  • Files reviewed: 4/4 changed files. The Narrowed input rows (Rejected values, Base, Failure guarded, Sources) stayed unchecked.
  • Unit tests at HEAD pass: "Tests: 19 passed, 19 total" (not in the output of run R3).
  • The end-to-end spec ran on WordPress 7.1.3 with PHP 8.3.35. All three Countdown cases pass cd /repo && sandbox-doctor.sh --plugin otter-blocks 2>&1 | tail -8 | cut -c1-250; curl -s -o /dev/null -w "%{http_code}\… (run R16, exit 0).
  • A scratch end-to-end spec repeated the label edit cd /workspace/checks/R2 && rm -f states*.json *.png && python3 - <<'EOF' p='/workspace/e2e/r2-lastchecked.spec.js' s=ope… (run R22, exit 0).
Untested areas
  • Narrowed input rows (Rejected values, Base, Failure guarded, Sources): open src/blocks/plugins/html-edit/attributes.js:289. Check whether a non-string html can arrive. A fallback to the synced markup is safe. A dropped valid edit is broken.
  • The business-hours-item end-to-end case timed out before HTML mode. It was not diagnosed.
  • Translated Countdown labels were not checked.

🤖 Automated review · run code-review-agent_6adb0d81b30623.80167388.


🤖 Review agent — review posted ✅ on d225a100 · changes requested · 2 findings · 27 min

Run code-review-agent_6adb0d81b30623.80167388 · trail

Comment thread src/blocks/plugins/html-edit/index.js

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes requested

The repeated-edit repair is fixed and tested. The earlier EDITABLE comment finding is still open, so reword that comment.

  • src/blocks/test/e2e/blocks/block-html-mode.spec.js:9 — comments The comment on EDITABLE says the edited markup "is read back into" comment attributes. The generated label cases do not work that way. Their label edit is discarded and restored from save, and expected keeps the old date. Reword the comment to cover both cases, for example: "Blocks whose edited markup is read back into attributes, or restored from save for generated markup, so the block stays valid."
Validation details
  • Files reviewed: 4/4 changed files. This run checked the 2 files changed since the prior review.
  • The two new Countdown end-to-end cases pass at HEAD on WordPress 7.1.3 with PHP 8.3.35 ls /opt/pw-browsers/ 2>&1; ls /opt/pw-browsers/chromium_headless_shell-1248/chrome-headless-shell-linux64/chrome-headles… (run R5, exit 0).
  • Both cases fail when the lastChecked = null reset is removed from the build cp /workspace/checks/blocks.nofix.js /repo/build/blocks/blocks.js && cd /repo/src/blocks/test/e2e && set -o pipefail; WP… printed Received: false (run R12).
  • The full HTML-mode spec at HEAD has 27 passed and 1 failed cp /workspace/checks/blocks.head.js /repo/build/blocks/blocks.js && cmp /workspace/checks/blocks.head.js /repo/build/blo… (run R13, exit 0). The failure is the earlier business-hours-item case.
  • A non-string html falls back to the synced markup, as before the change timeout 30 node /workspace/checks/K/check.mjs | tee /workspace/checks/K/run.log printed repair===synced===originalContent (run R4).
Untested areas
  • The business-hours-item end-to-end case fails before HTML mode opens. It fails the same way as in the earlier run. It was not diagnosed.
  • Translated Countdown labels were not checked.

🤖 Automated review · run code-review-agent_6adb1e13920071.02859296.


🤖 Review agent — review posted ✅ on 485143b6 · changes requested · 1 finding · 10 min

Run code-review-agent_6adb1e13920071.02859296 · trail

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

The PR passes. The EDITABLE comment now describes both the read-back and the restored-markup cases.

Validation details
  • Files reviewed: 4/4 changed files. This run checked the 1 file changed since the prior review. Two narrowed-input questions stayed unchecked: "Failure guarded" and "Sources".
  • The new comment in block-html-mode.spec.js matches the data-date case and the generated label cases.
  • The repeated-edit repair results come from run code-review-agent_6adb1e13920071.02859296, not rerun. Both new Countdown cases passed there. They failed without the lastChecked = null reset.
Untested areas
  • The "Failure guarded" and "Sources" narrowed-input questions for the html type check were not settled in this run.
  • The business-hours-item end-to-end case fails before HTML mode opens. It was not diagnosed.
  • Translated Countdown labels were not checked.

🤖 Automated review · run code-review-agent_6adb2242876e10.59697450.


🤖 Review agent — review posted ✅ on b0f548f4 · approved · 0 findings · 3 min

Run code-review-agent_6adb2242876e10.59697450 · trail

@pirate-bot
pirate-bot merged commit ac7d64b into development Oct 23, 2026
15 checks passed
@pirate-bot
pirate-bot deleted the bugfix/3127 branch October 23, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants