Skip to content

fix: list items keep class and style; anchors become ids (#344) - #363

Merged
ifahimreza merged 2 commits into
mainfrom
fix/344-list-item-class-anchor
Oct 13, 2026
Merged

ifahimreza merged 2 commits into
mainfrom
fix/344-list-item-class-anchor

Conversation

@ifahimreza

@ifahimreza ifahimreza commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #344

What

Blocks an AI app writes now carry their class, style and anchor on the page, not only in the block comment.

Why

On stage (page 264), edit-block with attrs: {"className": "s-ico-shield"} reported success, but the <li> had no class and the step lost its icon. An anchor on a group stayed in the comment and never became an id, so #works-with went nowhere. Both also make the editor see the block as changed.

How

  • core/list-item uses tag( 'li', classnames(), inline_style() ), like every other text block.
  • A new anchor() helper puts id="…" on the outer tag of every static block Saddle composes (all of them support anchors except core/html, which Saddle doesn't compose). The anchor also stays in the comment, so a later Saddle edit keeps it; the editor reads it from the id.
  • Same bug, wider: edit-block with attrs only kept a leaf's saved markup, so a drop cap, heading level or class never reached the page. It now recomposes a paragraph, heading, list item, separator or spacer from its current text (inline markup kept). Image, button and code still keep their markup, because their content isn't plain inner text.
  • An id made in the block editor (which leaves it out of the comment) is carried into anchor before recomposing, so it isn't dropped.
  • Changelog lines under 1.6.0 (the number is Fahim's). No new translatable strings.

Testing

  • vendor/bin/phpunit: 1519 tests, 8701 assertions, 1 skipped (PHP 8.2)
  • vendor/bin/phpcs: no new findings
  • New tests in tests/blocks-test.php: list item class and style (leaf and nested), the edit-block path from the issue, anchor → id on group, heading, paragraph, list item, spacer, separator, button and image, anchor escaping, attrs-only drop cap and heading level with inline markup kept, an editor-made anchor surviving an attrs-only edit on a heading and a group.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

- core/list-item is built with the same class and style helpers as every
  other text block, so a className reaches the <li> on the page.
- Every static block writes its anchor as the outer tag's id, and keeps it
  in the comment so later Saddle edits keep it.
- edit-block with attrs only recomposes a paragraph, heading, list item,
  separator or spacer from its current text, so new classes, a drop cap or
  a heading level reach the markup. An id made in the editor is carried
  into the anchor first. Image, button and code keep their saved markup.

Closes #344

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ifahimreza ifahimreza linked an issue Oct 13, 2026 that may be closed by this pull request
@ifahimreza
ifahimreza merged commit d0ad8f1 into main Oct 13, 2026
8 checks passed
@ifahimreza
ifahimreza deleted the fix/344-list-item-class-anchor branch October 13, 2026 23:21
@ifahimreza ifahimreza mentioned this pull request Oct 22, 2026
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.

Block author drops className and styles on core/list-item

1 participant