Repository navigation
Prevented Countdown block breakage when editing as HTML - #3131
Conversation
Bundle Size Diff
|
|
Plugin build for b0f548f is ready 🛎️!
|
E2E TestsPlaywright Test Status: See serial and parallel matrix jobs Performance ResultsserverResponse: {"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} |
There was a problem hiding this comment.
🟡 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, { |
There was a problem hiding this comment.
🟡 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—commentsThe comment onEDITABLEsays the edited markup "is read back into" comment attributes. The newgenerated labelcases do not work that way. Their label edit is discarded and restored fromsave, andexpectedkeeps the old date. Reword the comment to cover both cases, for example: "Blocks whose edited markup is read back into attributes, or restored fromsavefor 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-stringhtmlcan arrive. A fallback to the synced markup is safe. A dropped valid edit is broken. - The
business-hours-itemend-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
There was a problem hiding this comment.
🟡 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—commentsThe comment onEDITABLEsays the edited markup "is read back into" comment attributes. Thegenerated labelcases do not work that way. Their label edit is discarded and restored fromsave, andexpectedkeeps the old date. Reword the comment to cover both cases, for example: "Blocks whose edited markup is read back into attributes, or restored fromsavefor 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 = nullreset is removed from the buildcp /workspace/checks/blocks.nofix.js /repo/build/blocks/blocks.js && cd /repo/src/blocks/test/e2e && set -o pipefail; WP…printedReceived: 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 earlierbusiness-hours-itemcase. - A non-string
htmlfalls back to the synced markup, as before the changetimeout 30 node /workspace/checks/K/check.mjs | tee /workspace/checks/K/run.logprintedrepair===synced===originalContent(run R4).
Untested areas
- The
business-hours-itemend-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
There was a problem hiding this comment.
🟢 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.jsmatches thedata-datecase and thegenerated labelcases. - 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 = nullreset.
Untested areas
- The "Failure guarded" and "Sources" narrowed-input questions for the
htmltype check were not settled in this run. - The
business-hours-itemend-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

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 disablingsupports.html, preserving the behavior introduced in #3072.Checklist before the final review