Skip to content

Add emoji reactions on blocks (stacked on #83538) - #83169

Open
adamsilverstein wants to merge 37 commits into
try/notes-emoji-picker-autocomplete-gridfrom
add/block-emoji-reactions
Open

adamsilverstein wants to merge 37 commits into
try/notes-emoji-picker-autocomplete-gridfrom
add/block-emoji-reactions

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Claude Code wrote this description and brought it up to date with the block options menu version, new screenshots included.

Summary

Stacked on top of #83538 (standalone against trunk; it replaced #78176 and #76767, which are closed) - review that first. Part of #75144, which set out to make reaction a comment type that can attach to more than a note.

This PR lets a user react to a block itself, not only to a note on it. An "Add reaction" item in the block options menu, right after "Add note", brings the block's reactions into the Notes sidebar, where the same emoji picker notes use lives. They show up in the Notes sidebar: at the head of the block's first thread when it has a note, or as an entry of their own when it does not.

It also turns the "a reaction must have a parent note" rules in the REST layer into a small target abstraction, so posts and media can follow later as two more branches rather than a rewrite. Those two are documented but not implemented here.

Where it lives

  • Block options menu: "Add reaction" sits right after "Add note" (moved out of the toolbar after feedback from @fcoveram and @annezazu, so solo writers don't get another toolbar button). It is disabled on a classic block (no block-level anchor to write) and on a locked block that has none yet. Choosing it lists the block in the sidebar even before its first reaction and focuses the "Add block reaction" trigger.
  • Notes sidebar: a block's reactions render as a row (block icon, pills, an "Add block reaction" trigger). When the block has an unresolved note the row leads that thread, so the floating view and the full sidebar agree. When it has no note, the block gets its own entry that behaves like a thread: click or Enter selects the block, arrow keys move between entries, "Back to block" returns focus.
  • Choosing "Add reaction" opens the notes sidebar if it is not already showing, the way adding a note does.

No design exists for this yet in #82324, so the sidebar placement is still a first pass.

Data storage

A block has no persistent id, so the first reaction on a block mints a short anchor and writes it to the block's metadata.reactionsId attribute, mirroring how notes anchor through metadata.noteId. That makes the post dirty until it is saved, exactly as the first note on a block does. Later reactions reuse the anchor.

Each reaction is still one row in wp_comments with comment_type reaction. On a block it is a top-level row (comment_parent 0) on the post, anchored through a new _wp_reaction_block comment meta.

flowchart LR
  P["wp_posts<br/>post 12<br/>block metadata.reactionsId = k3f9a2xq"] --> N["type: note<br/>ID 100"]
  N -->|comment_parent| R1["type: reaction<br/>parent 100<br/>content: 2764"]
  P -->|comment_post_ID, parent 0| R2["type: reaction<br/>meta _wp_reaction_block: k3f9a2xq<br/>content: 2764"]
  P -->|comment_post_ID, parent 0| R3["type: reaction<br/>meta _wp_reaction_block: k3f9a2xq<br/>content: 1f44d"]
  R2 --> S["block_reaction_summary on post 12<br/>k3f9a2xq: 2764 count 1, 1f44d count 1"]
  R3 --> S
Loading

Writing. POST /wp/v2/comments with type: reaction, post, block: <anchor> and the emoji's hex key (the same hex-only storage #83538 uses for notes). A new resolver (gutenberg_resolve_reaction_target() in lib/compat/wordpress-7.2/block-reactions.php) maps a request to a note target (parent) or a block target (block), and rejects both or neither. The anchor is validated by schema pattern (^[a-z0-9]{6,16}$) before the controller runs. Uniqueness and the concurrent-duplicate convergence from #76767 now scope by post and anchor - on its own a zero parent matches every top-level comment site-wide, which is the one real trap in generalizing this.

Reading. The post resource gains a read-only block_reaction_summary field in edit context, keyed by anchor and then by hex key with the same { count, reacted, my_reaction_id } shape as a note's reaction_summary. One aggregate query, computed for single-item requests only, so a list of posts never pays for it. The editor reads it off the post record it already holds, folds a toggle into the cached record as a partial (so unsaved edits survive) and refetches only the field afterwards. GET /wp/v2/comments?post=&parent=0&block=&type=reaction lists who reacted, for the pill tooltips.

Permissions. Unchanged in effect: reacting needs edit_post on a notes-capable post type, the same as a note. The permission check now names the flag each gate reads instead of folding reactions into the note flag, so a target-specific policy later (readers reacting to a published post, say) is a one-line change at that gate. A reaction the user may not create reports rest_cannot_create_reaction rather than the note error.

Orphans. Nothing on the server reconciles anchors with content on save, deliberately: reactions are created before the anchor is saved, so a save from stale content (another collaborator, a plugin calling wp_update_post()) would trash live reactions. The client just does not list an anchor with no matching block, and undo restores the block with its anchor and its pills. Permanently deleting the post removes the rows and their meta as it does for any comment.

Does the data model generalize?

Checked against the plugin and the Core backend in WordPress/wordpress-develop#10930. The storage layer already accepts a reaction with no parent on any post, and the internal-type list hides the type from front-end queries, counts and the admin list regardless of target. Every "must be a note" rule lived in the REST controller and the cascade hooks, and those are what this PR generalizes. A post or media target would need a new resolver branch, a reaction_summary field on its resource reusing the same aggregate query grouped by comment_post_ID, and its own read policy (reactions are not world-readable today, so a public count needs one). The row shape and the storage key do not change.

Testing

Test in WordPress Playground

For multi-user testing, try https://wordpress.org/plugins/user-switching/

  1. Check out the branch (it includes Add emoji picker with Autocomplete grid  #83538), npm run build.
  2. Add a paragraph, open the block options menu (three dots) and choose "Add reaction". Pick an emoji from the sidebar trigger.
  3. The notes sidebar opens with a "Reactions on Paragraph" entry showing the pill. In the code editor the block now carries metadata.reactionsId.
  4. React again with a different emoji: the anchor is unchanged and the second pill joins the first. Click a pill to remove your reaction; removing the last one focuses the block.
  5. Save the draft and reload: the entry and pills are back.
  6. Add a note to the same block. The reactions row moves to the head of the note's thread, and the note keeps its own "Add reaction" trigger and pills.
  7. Switch users, hover a pill: the tooltip names who reacted. React as the second user to see the count go up.
  8. Delete the block: the entry disappears. Undo: it returns.
  9. Keyboard: open the block options menu, choose "Add reaction" with Enter: focus lands on "Add block reaction" in the sidebar; Enter opens the picker and arrow keys move through the grid.
  10. GET /wp/v2/posts/<id>?context=edit carries block_reaction_summary; ?context=view does not; the posts collection returns null for it.

Automated: 5 Playwright specs under Block Reactions in block-notes.spec.js (the full notes spec, 71 tests, passes locally), plus phpunit cases across Block_Reactions_Test and the Gutenberg comments controller test (120 pass locally).

Screenshots

Screencast

block-reactions-screencast.mp4

Adding two reactions to a paragraph from the block options menu, then a note on the same block: the reactions row moves to the head of the note's thread.

"Add reaction" after "Add note" in the block options menu Reactions in the floating notes sidebar
Block options menu open on a paragraph, with Add reaction listed right after Add note Editor with the paragraph selected and a floating sidebar entry showing Heart and Rocket pills
Sidebar entry for a block with no note Reactions row leading a note thread
Reactions on Paragraph entry with Heart and Rocket pills and an add reaction button A note thread with the block's Heart and Rocket reaction row above the note

Types of changes

  • Add lib/compat/wordpress-7.2/block-reactions.php: _wp_reaction_block comment meta, the target resolver and query scoping, the block_reaction_summary post field, a rest_comment_query filter for listing by anchor.
  • Accept a top-level block param in the 7.2 comment controller; report the anchor on reaction responses; split the note/reaction permission flags.
  • Add metadata.reactionsId helpers and a ReactionTarget type; generalize ReactionDisplay to a note or block target (the note request is byte-identical); let AddReactionButton take a label and class name.
  • Add useBlockReactionSummary and useBlockReaction( clientId ) (the block counterpart of useReaction( note )); merge reacted blocks into useNoteThreads.
  • Add BlockReactionsRow, BlockReactionsEntry and the "Add reaction" block options menu item; preserve metadata.reactionsId through one-to-one block transforms.

Open questions

AI Use

Claude Code wrote the code and this description over a few rounds of back and forth, starting from a plan we agreed on. I will review and test.

Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
https://claude.ai/code/session_01Bb4BE9PBpaTHtGMhp4ASAQ

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: fcoveram <fcoveram@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added [Package] Editor /packages/editor [Package] Block editor /packages/block-editor labels Sep 19, 2026
@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

📦 Bundle size

Size Change: +2.3 kB (+0.03%)

Total Size: 8.4 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 517 kB +17 B (0%)
build/scripts/editor/index.min.js 638 kB +2.2 kB (+0.35%)
build/styles/editor/style-rtl.css 33.2 kB +20 B (+0.06%)
build/styles/editor/style-rtl.min.css 28.4 kB +22 B (+0.08%)
build/styles/editor/style.css 33.3 kB +19 B (+0.06%)
build/styles/editor/style.min.css 28.3 kB +23 B (+0.08%)

847de05 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 0723856 try/notes-emoji-picker-autocomplete-grid % Change
timeToFirstByte 53.45 ms +8.98% -8.79% 51.55 ms +7.47% -7.95% 3.69%
largestContentfulPaint 86 ms +13.95% -6.98% 84 ms +4.76% -7.14% 2.38%
lcpMinusTtfb 34.85 ms +19.08% -13.34% 32 ms +2.19% -8.44% 8.91%
wpBeforeTemplate 25.2 ms +18.81% -3.29% 24.81 ms +20.11% -2.46% 1.57%
wpTemplate 22.03 ms +13.16% -7.81% 21.31 ms +5.87% -6.9% 3.38%
wpTotal 49.26 ms +9.89% -8.02% 47.72 ms +7.71% -7.75% 3.23%
wpMemoryUsage 7.69 MB +0% -0% 7.68 MB +0% -0% 0.09%
wpDbQueries 17 +0% -0% 17 +0% -0% 0%

front-end-classic-theme

Metric 0723856 try/notes-emoji-picker-autocomplete-grid % Change
timeToFirstByte 41.85 ms +6.21% -5.73% 36 ms +9.31% -2.78% 16.25%
largestContentfulPaint 92 ms +0% -4.35% 80 ms +5% -5% 15%
lcpMinusTtfb 48.95 ms +3.68% -1.74% 43.25 ms +1.85% -4.62% 13.18%
wpBeforeTemplate 22.1 ms +9.82% -4.12% 21.35 ms +8.85% -1.69% 3.51%
wpTemplate 15.63 ms +5.89% -3.58% 11.82 ms +2.88% -2.88% 32.23%
wpTotal 38.66 ms +5.85% -5.17% 33.14 ms +10.05% -2.29% 16.66%
wpMemoryUsage 6.33 MB +0% -0% 6.17 MB +0% -0% 2.75%
wpDbQueries 14 +0% -0% 10 +0% -0% 40%

media-processing

Metric 0723856 try/notes-emoji-picker-autocomplete-grid % Change
mediaProcessingJpeg 350.57 ms +1.21% -0.84% 354.32 ms +3.65% -1.08% -1.06%
mediaProcessingAvif 5153.46 ms +0.88% -0.35% 5110.94 ms +0.68% -0.13% 0.83%
mediaProcessingJpegToAvif 3592.7 ms +0.52% -0.35% 3569.75 ms +0.43% -0.44% 0.64%

media-upload

Metric 0723856 try/notes-emoji-picker-autocomplete-grid % Change
jpegUploadProcessing 1398.03 ms +1.99% -0.41% 1408.13 ms +2.07% -0.62% -0.72%
pngUploadProcessing 216.62 ms +4.19% -7.36% 215.17 ms +3.95% -8.25% 0.67%
largeJpegUploadProcessing 1398.39 ms +1.02% -1.08% 1407.97 ms +1.37% -1.09% -0.68%
multipleImageUploadProcessing 1505.94 ms +0.91% -1.35% 1494.66 ms +5.86% -1.24% 0.75%

post-editor

Metric 0723856 try/notes-emoji-picker-autocomplete-grid % Change
serverResponse 379.24 ms +5.84% -2.14% 417.82 ms +2.79% -6.85% -9.23%
firstPaint 293.98 ms +48.32% -20.15% 253.74 ms +21.27% -26.66% 15.86%
domContentLoaded 995.5 ms +1.72% -1.83% 1019.47 ms +1.37% -1.9% -2.35%
loaded 996.58 ms +1.74% -1.84% 1020.53 ms +1.38% -1.86% -2.35%
firstContentfulPaint 439.4 ms +1% -2.24% 445.52 ms +2.18% -5.81% -1.37%
firstBlock 2877.91 ms +0.78% -0.63% 2908.07 ms +0.49% -0.94% -1.04%
type 17.56 ms +1.59% -4.73% 17.54 ms +6.84% -3.48% 0.11%
typeWithoutInspector 17.48 ms +3.6% -6.58% 17.49 ms +2.63% -2.12% -0.06%
typeWithTopToolbar 23.57 ms +0.81% -2.93% 22.48 ms +7.21% -3.38% 4.85%
typeContainer 8.31 ms +3.73% -2.65% 8.58 ms +7.34% -4.2% -3.15%
focus 105.41 ms +6.59% -6.79% 108.02 ms +6.93% -5.93% -2.42%
firstFocus 205.43 ms +0% -0% 219.74 ms +0% -0% -6.51%
selectAll 426.37 ms +11.2% -2.15% 432.61 ms +4.11% -2.07% -1.44%
listViewOpen 71.09 ms +6.34% -7.65% 73.06 ms +3.01% -4.07% -2.7%
inserterOpen 37.82 ms +18.54% -2.67% 41.06 ms +2.68% -10.23% -7.89%
inserterHover 12.33 ms +9.49% -6.89% 12.25 ms +7.35% -4.33% 0.65%
inserterSearch 9.1 ms +9.78% -2.53% 8.62 ms +5.22% -2.78% 5.57%
loadPatterns 620.69 ms +4.65% -1.33% 636.76 ms +3.7% -5.78% -2.52%
wpTotal 369.15 ms +5.85% -2.19% 408.07 ms +2.78% -6.94% -9.54%
wpMemoryUsage 13.30 MB +0% -0.04% 13.29 MB +0% -0% 0.08%
wpDbQueries 54 +0% -11.11% 54 +0% -1.85% 0%

site-editor

Metric 0723856 try/notes-emoji-picker-autocomplete-grid % Change
serverResponse 402.87 ms +1.76% -5.04% 408.9 ms +2.57% -6.08% -1.47%
firstPaint 273.25 ms +16.09% -20.85% 239.37 ms +9.02% -7.08% 14.15%
domContentLoaded 1103.95 ms +1.46% -2.55% 1114.07 ms +0.74% -1.55% -0.91%
loaded 1105.07 ms +1.46% -2.55% 1115.19 ms +0.74% -1.55% -0.91%
firstContentfulPaint 440.23 ms +2.25% -5.65% 444.95 ms +1.81% -3.16% -1.06%
firstBlock 4189.62 ms +0.74% -1.42% 4184.89 ms +0.33% -3.1% 0.11%
type 17.45 ms +6.59% -1.49% 16.84 ms +6.89% -1.6% 3.62%
navigate 122.38 ms +7.37% -7.16% 111.77 ms +4.3% -4.56% 9.49%
loadPatterns 1264.69 ms +3.5% -10.38% 1214.04 ms +25.76% -1.98% 4.17%
loadPages 1001.52 ms +1.74% -1.09% 980.62 ms +0.3% -0.39% 2.13%
wpTotal 393.68 ms +1.81% -5.19% 399.63 ms +2.67% -6.2% -1.49%
wpMemoryUsage 12.32 MB +0% -0% 12.33 MB +0% -0% 0%
wpDbQueries 44 +2.27% -0% 43 +2.33% -0% 2.33%

847de05 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

All navigation links should default to the body color and submenus and mobile overlay should default to a white background with black text in /test/e2e/specs/editor/blocks/navigation-colors.spec.js, passed after 1 failed attempt.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → GET http://localhost:8889/wp-json/wp/v2/pages?per_page=100&status=publish%2Cfuture%2Cdraft%2Cpending%2Cprivate%2Ctrash
    - user-agent: Playwright/1.63.0 (x64; ubuntu 24.04) node/24.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 503f970e01
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1791710971%7Cj6nEW5KdUModMQp48qBwNB4pZ2dJymu7ZaKizUlApXU%7C134b5670d848beb1d59e27cc653d9e9ede40c6a763fc447587add50d53f4e3fb; wp-settings-time-1=1791538225

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:112:39)
    at RequestUtils.deleteAllPages (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/pages.ts:44:27)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-colors.spec.js:38:17

847de05 Run

@adamsilverstein adamsilverstein changed the title Notes: Add emoji reactions on blocks (stacked on #78176) Add emoji reactions on blocks (stacked on #78176) Sep 21, 2026
@fcoveram

Copy link
Copy Markdown
Contributor

I’m not quite sure about the value of this change. It feels like a subfeature of adding notes and reacting there, rather than making the action more visible at the toolbar level.

Perhaps a new section in the toolbar menu for both adding a note and adding a reaction would be a better place for this.

CleanShot 2026-09-25 at 12 50 19@2x

The notes and reaction panel occupy a significant portion of the screen. I might be missing context, but having the right-side panel open without an active state indicator in the editor header feels inconsistent and breaks the current heuristic.

CleanShot 2026-09-25 at 12 51 30@2x

@annezazu

Copy link
Copy Markdown
Contributor

I think that design takes this change too far in terms of real estate in the toolbar. We need to think about the balance between folks collaborating vs folks writing solo and not disrupting those simply writing with more bells and whistles, so to speak.

adamsilverstein and others added 16 commits September 30, 2026 11:38
Cover the REST contract (a top-level block anchor instead of a parent
note, uniqueness scoped by post and anchor, a block_reaction_summary
field on the post) and the editor flow (toolbar trigger, sidebar
listing, persistence, undo) before the implementation lands, so each
behavior is proven red first.

Claude-Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
Add block-reactions.php with a _wp_reaction_block comment meta, a
resolver that maps a reaction request to a note or a block target, and
query scoping that keys a block target by post and anchor. A zero parent
alone matches every top-level comment site-wide, so the extra scope is
what keeps uniqueness and convergence correct for block targets.

Expose a read-only block_reaction_summary field on notes-capable post
types in edit context, computed with one aggregate query and only for
single-item requests so post lists never pay for it. A rest_comment_query
filter lets the editor list a block's reactions by anchor to name who
reacted.

Post-level targets stay a reserved, rejected branch of the resolver
until they have a read and create policy of their own.

Claude-Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
Replace the inline parent-note checks with the shared target resolver
and accept a top-level block anchor, validated by schema pattern before
the controller runs. A block target stores as a top-level row with the
anchor in comment meta, written by wp_insert_comment before the
convergence query so concurrent duplicates still collapse.

Name the permission gates by what they read so reactions no longer
inherit note policy implicitly, report rest_cannot_create_reaction for a
reaction the user may not create, and look the post up before the
capability gate so a missing post reports rest_comment_invalid_post_id.

Claude-Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
Introduce the reaction target type and the helpers that mint, read and
write a block's metadata.reactionsId anchor, fold a toggle into a cached
summary, and build the per-target REST query. Preserve the anchor
through one-to-one block transforms the way noteId already is, so a
paragraph turned into a heading keeps its reactions.

Claude-Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
Replace the noteId prop on ReactionDisplay and AddReactionButton with a
target so the same pills, picker and reactor-name lookup serve a block.
The note request is unchanged; a block target lists by post, parent 0
and anchor. AddReactionButton gains a label, a wrapper class and a
renderToggle so a toolbar button can open the same picker, and
ReactionDisplay gains onRemoveLast for a host that unmounts when its
last pill goes.

Claude-Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
Read the post's block_reaction_summary and merge each reacted block into
the note threads in document order: at the head of the block's first
unresolved thread, or as an entry of its own when the block has no
note. Toggling a block reaction mints the anchor synchronously, posts or
deletes the reaction comment, folds the result into the cached post
record as a partial so unsaved edits survive, then refetches only the
summary for other users' counts.

Claude-Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
Add a reactions row (block icon, pills, "Add block reaction" trigger)
that leads a block's first thread, and a standalone entry that shares
the thread shell for a block with reactions but no note, so selection,
keyboard navigation, floating placement and block highlighting work
unchanged. The row is its own hover target for the trigger reveal.

Claude-Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
Fill the note toolbar slot with a smiley button that opens the reaction
picker for the selected block, beside the note avatar indicator. It is
disabled on a classic block, which has no block-level anchor to write,
and on a locked block that has none yet. Synthetic reaction entries are
kept out of the note highlight styles and the avatar indicator's thread
lookup.

Claude-Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
The floating sidebar only takes over once the user closes whatever
complementary area is active, so a reaction added from the toolbar
landed in a sidebar that never opened. Report success from the toggle
and enable the notes area on it, the way adding a note already does.

Claude-Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
Add changelog entries for the editor and block-editor packages and a
"Block reactions" section to the collab sidebar README covering the
anchor, the summary read path and the thread placement rule.

Claude-Session: https://claude.ai/code/session_01XFFaaNbo3UJuVm8so8Zsrj
The toolbar button borrowed the exported inline smiley from the picker,
which the base branch has now replaced with the reaction icon from
@wordpress/icons. Import that icon directly instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GaU1KRgXC1a2DBq9NaPpgx
Collection responses carried block_reaction_summary: null, and core-data
merges single and collection responses into one per-record cache. A
collection that included the edited post, such as a Query Loop preview,
erased its loaded summary, hid the block's reactions and could route the
next toggle to a duplicate add. Strip the uncomputed field instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVG6n1U8ALSytqDGniZYGF
Selecting a block-reactions entry selects the entry, then its block. The
block transition synced the selection to the block's primary note, which
a reactions-only block does not have, so the entry was deselected right
away for both pointer and keyboard. Keep an explicitly selected thread
that belongs to the newly selected block.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NVG6n1U8ALSytqDGniZYGF
The block-reactions-row test registered core/paragraph without an
apiVersion, so the blocks package emitted its API version deprecation
warning and the Vitest console guard failed the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GqepyjmFSryBt88j6f6ubY
WP_UnitTestCase unregisters every meta key in tear_down, so the init
registration only survives for the first test of the run. The
registry assertion failed whenever another test ran before it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GqepyjmFSryBt88j6f6ubY
The block toolbar now includes the "React to block" button between
More and Options, so the keyboard navigation spec must step through it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GqepyjmFSryBt88j6f6ubY
@adamsilverstein adamsilverstein changed the title Add emoji reactions on blocks (stacked on #78176) Add emoji reactions on blocks (stacked on #83538) Sep 30, 2026
@adamsilverstein
adamsilverstein force-pushed the add/block-emoji-reactions branch from 77dbb23 to bea9dd6 Compare September 30, 2026 18:38
adamsilverstein and others added 6 commits October 2, 2026 16:04
…ete-grid' into add/block-emoji-reactions

# Conflicts:
#	packages/editor/src/components/collab-sidebar/README.md
#	packages/editor/src/components/collab-sidebar/reactions/add-reaction-button.tsx
#	packages/editor/src/components/collab-sidebar/style.scss
Trims the PR to the feature code, as #83538 did for the note reactions;
the e2e suite covers the same behavior end to end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mc4Menp91Vyvh9AryqivSN
Mirrors useReaction( note ) from #83538 so the row and the toolbar button
read and toggle a block's reactions themselves, instead of having the
toggle and summary threaded through Notes, NoteThread and the entry.

The thread-list merge moves out of useNoteThreads into
addBlockReactionEntries, leaving the note ordering loop as it was, and the
helpers only the unit tests needed (injected anchor generator, metadata
and delta wrappers, the Math.random fallback) are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mc4Menp91Vyvh9AryqivSN
Folds the anchor, reuse and removal checks into one flow, and drops the
picker keyboard test and the note-reaction half of the mixed test: the
note reaction suite and the toolbar navigation spec already cover them.
The toolbar trigger is now an Autocomplete combobox, so the helper finds
it by that role.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mc4Menp91Vyvh9AryqivSN
The picker's Autocomplete trigger cannot live in the block toolbar: the
toolbar's roving focus remounts it on mousedown, and the popup closes on
mouseup. The toolbar button is now a plain ToolbarButton that lists the
block in the sidebar, even before its first reaction, and focuses the
row's "Add block reaction" trigger. That keeps one picker trigger per
target and drops the custom trigger prop from AddReactionButton.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mc4Menp91Vyvh9AryqivSN
…ete-grid' into add/block-emoji-reactions

# Conflicts:
#	lib/compat/wordpress-7.2/class-gutenberg-rest-comment-controller-7-2.php
#	packages/editor/CHANGELOG.md
@adamsilverstein

Copy link
Copy Markdown
Member Author

The goal here was leaving a reaction to a block, for example a smiley on an image.

I'll try cleaning this up and moving the interaction to the ellipsis menu, so Add Note and Add Reaction.

adamsilverstein and others added 4 commits October 2, 2026 19:27
…emoji-reactions

Block reactions now store the emoji hex key, matching the base branch's
hex-only storage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bb4BE9PBpaTHtGMhp4ASAQ
Reviewers felt a dedicated toolbar button gave block reactions too much
weight next to the writing tools. "Add reaction" now sits after
"Add note" in the block options menu and opens the block's reactions in
the sidebar as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bb4BE9PBpaTHtGMhp4ASAQ
The reaction control moved from the block toolbar into the block
options menu, so the toolbar no longer has a "React to block" stop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bb4BE9PBpaTHtGMhp4ASAQ
Replace the CSS class locator with the row's accessible group name and
share one pill helper across the block reaction specs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bb4BE9PBpaTHtGMhp4ASAQ
@adamsilverstein

Copy link
Copy Markdown
Member Author

@jasmussen I added a screencast to the description and you can also try Playground. I like the overall idea of reacting to blocks, but I'm not sure I like how it works here beside Notes.

…k-emoji-reactions

Key the base's shared reactor-name cache by reaction target, so block
pills share one fetch the same way note pills do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bb4BE9PBpaTHtGMhp4ASAQ
@jasmussen

Copy link
Copy Markdown
Contributor

You're a freight-train with how many PRs you open. Impressive!

On this one, it actually touches on a principle I think is very important to establish, which I suggest should be: notes are notes. Whether you add a note and write text, or whether you make an edit while in suggest mode, or even if we end up adding lint tools in the canvas then lint-notices are notes. The key being: each of them come with a thread where you can respond to a particular suggestion or add notes to a lint item. Or, you could react.

In other words, I don't see a threadless "Reaction" alone as something that shouold show up in the notes tray. It could be a reaction note, the difference being that it's also just a note, with a thread, it could read out "Adam reacted with 👍", and then it's a note thread.

I believe this principle of a single note type with threads being fairly important to not increase the review surface. Yes we can have many different types of contents inside a note, but a note is a note.

So for me the question is one of: should reactions have its own menu item? And in my opinion, no, because the menu is already rather complicated. What do you think?

I defer to @fcoveram if he has instincts.

@fcoveram

fcoveram commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Nothing much to add, but just second what @jasmussen said above.

@adamsilverstein

Copy link
Copy Markdown
Member Author

So for me the question is one of: should reactions have its own menu item? And in my opinion, no, because the menu is already rather complicated. What do you think?

Probably not.

I mostly wanted to explore what reactive with emoji to blocks would look like, to make sure how we are building reactions enables that in the future.

In other words, I don't see a threadless "Reaction" alone as something that shouold show up in the notes tray. It could be a reaction note, the difference being that it's also just a note, with a thread, it could read out "Adam reacted with 👍", and then it's a note thread.

That makes sense, so reactions become a kind of note. I'm trying to imagine adding reactions in different places in the editor, for example in the media library.

I do see that Google docs enables an emoji reaction on a selection that isn't a comment.

adamsilverstein and others added 7 commits October 6, 2026 15:57
…k-emoji-reactions

Adopt the base's `{ count, current_user_reaction }` summary shape for
block reactions too, and move "Add reaction" on a block onto the canvas
margin floating notes that replaced the floating sidebar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEnYgh9tWGG6ptNTQrZK6R
The base lowercased the curated reaction labels, so the block reaction
specs could no longer find "Heart" or "Rocket" in the picker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEnYgh9tWGG6ptNTQrZK6R
…ete-grid' into add/block-emoji-reactions

# Conflicts:
#	packages/editor/src/components/collab-sidebar/README.md
#	packages/editor/src/components/collab-sidebar/hooks.js
#	packages/editor/src/components/collab-sidebar/index.jsx
#	packages/editor/src/components/collab-sidebar/note-thread.jsx
#	packages/editor/src/components/collab-sidebar/notes.jsx
…ete-grid' into add/block-emoji-reactions

# Conflicts:
#	lib/compat/wordpress-7.2/class-gutenberg-rest-comment-controller-7-2.php
#	packages/editor/src/components/collab-sidebar/reactions/use-reaction.ts
Block reactions share the summary delta helper and the toggle flow, so
they had the same stale-removal and repeated-click problems as note
reactions. The resolver test fixtures now create open notes, since an
approved note is a resolved thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7rwHtVAa37GWJPC8P3Cwd
…k-emoji-reactions

Follow the base's note selection rework: select a block's reactions
through `pickNote`, so an empty new-note form is discarded the same way,
and pass the block's reactions to the picker trigger so it marks the
user's own reactions too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEnYgh9tWGG6ptNTQrZK6R
@t-hamano

t-hamano commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@adamsilverstein, how about changing the base branch of this PR from #83538 to #76767? This is because #76767 is the one currently viable, not #83538.

@adamsilverstein

Copy link
Copy Markdown
Member Author

Good idea @t-hamano. I'll work on that when I'm back at my computer tomorrow.

@dmsnell dmsnell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just some minor comments. this is not meant to be a full review; just trying to get at it where I can with the time I have. if I can come back and focus more on this I will.

*/
function gutenberg_get_reaction_block_anchor_pattern() {
return '^[a-z0-9]{6,16}$';
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this warrant a function? at least as a const it would just be a string literal, but as a function call it adds runtime overhead, meaningless as that would be in the big picture.

the JSDoc can attack to a const. just curious why the function exists

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

a constant would probably be better

$anchor = (string) $row->block;
$hex_key = wp_strip_all_tags( $row->hex_key );

$summary[ $anchor ][ $hex_key ] = array(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is hex_key the code point for the reaction in hex?

| comment_content |
| "1F384"         |

(for 🎄)

I find hex_key as the name for comment content confusing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I find hex_key as the name for comment content confusing.

It is the key for the reaction in hex, or i guess the code point. would you call it 'comment_content' instead?

$summary = array();
foreach ( (array) $rows as $row ) {
$anchor = (string) $row->block;
$hex_key = wp_strip_all_tags( $row->hex_key );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what’s the goal here? I generally try and steer people away from wp_strip_all_tags() due to its poor HTML parsing.

if we are trying to match some code point sequence, perhaps a positive affirmation of the reaction would be helpful?

if ( strspn( $row->hex_key, '0123456789ABCDEFabcdef' ) !== strlen( $row->hex_key ) {
	continue;
}

$codepoint = inval( $row->hex_key, 16 );
if (
	$codepoint > 0x1FFFF || // Beyond the highest codepoint.
	( $codepoint >= 0xD800 && $codepoint <= 0xDFFF ) // Unpaired surrogates.
) {
	continue;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good idea

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The same pattern is already in trunk from #76767, so I split this out: #86775

Claude worked through the change, here is where it differs from your snippet:

A key can hold more than one code point (skin tones and flags are sequences joined by -, eg. 1f44d-1f3fd), so the check splits on - and tests each part instead of running intval() over the whole string.

Each part has to be lowercase hex, no higher than 0x10FFFF and not a surrogate. Rows that fail are left out of the summary, and the other reads compare the stored content to the validated key exactly, so wp_strip_all_tags() is gone from the controller.

Core trunk has the same calls since https://core.trac.wordpress.org/changeset/64488, so it needs the same patch there.

Does that match what you had in mind?

This branch has not been deployed

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

Labels

[Package] Block editor /packages/block-editor [Package] Editor /packages/editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants