Skip to content

Add emoji reactions to notes ❤️ 🎉 😄 👀 🚀 - #76767

Merged
adamsilverstein merged 214 commits into
trunkfrom
add-notes-emoji-reactions-try-addditional-comment-type
Oct 16, 2026
Merged

adamsilverstein merged 214 commits into
trunkfrom
add-notes-emoji-reactions-try-addditional-comment-type

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Mar 23, 2026 •

Copy link
Copy Markdown
Member

Test in WordPress Playground

❤️ 🎉 😄 👀 🚀

Claude reread the current branch and rewrote this description to match it:

Summary

Closes #75144

Adds emoji reactions to block notes, limited to a fixed set of five: heart, celebration, smile, eyes and rocket. The full searchable emoji picker lives in a follow-up PR stacked on this one - per @t-hamano's request, so library and bundling decisions can be reviewed separately. A filter for the preset list is split out too, in #84200.

The PHP lives in lib/compat/wordpress-7.2/, with the core backport in WordPress/wordpress-develop#10930.

Storage: reactions as a custom comment type

Reactions are stored as individual reaction comment records (one per user, emoji and note), as suggested by @swissspidy, in preference to JSON blobs in comment meta:

comment_type     = 'reaction'
comment_parent   = <note ID>
comment_content  = <emoji hex key>   // e.g. '2764' for ❤️
comment_approved = '1'               // always
user_id          = <reacting user>

This aligns with WordPress data patterns (similar to the React plugin), gives every reaction a real author, date and ID, and could eventually extend to regular comments.

The emoji is stored as its hex key: lowercase code points padded to four digits, joined by -, with U+FE0F stripped. ASCII keys sidestep utf8 vs utf8mb4 portability issues on the comments table and give stable grouping in the summary query. The server accepts exactly the five keys in the set and rejects anything else, including raw emoji.

Keeping reactions out of the way

Like notes, reactions are internal and never show up as regular comments. lib/compat/wordpress-7.2/note-reactions.php keeps them out of:

  • comment queries that don't ask for them, and the wp-admin/edit-comments.php list table
  • post comment counts
  • comment feeds, and the get_lastcommentmodified() lookup behind the feed's Last-Modified header
  • a note's children link in the REST response, so a note with reactions but no replies doesn't advertise children

Reactions also follow their note: trashing a note trashes its reactions, and permanently deleting a note deletes them, instead of core reparenting them as orphaned rows that still carry the reactor's identity.

REST API

Creating a reaction goes through the existing POST /wp/v2/comments route with type: 'reaction', and the controller adds a few rules:

  • The parent has to be a note, and the thread can't be resolved (400). Resolving a thread is treated as archiving the conversation.
  • Content has to be one of the five hex keys (400).
  • A reaction is always approved; any other status is rejected (400).
  • One reaction per user per emoji per note (409). Only approved reactions count, so removing a reaction and adding it back works.

Removing a reaction is a force delete of that comment.

Efficient reaction loading

Each note in the response carries a read-only reaction_summary field, { [hexKey]: { count, current_user_reaction } }, where current_user_reaction is the current user's reaction ID (used to remove it) or 0. The schema and population live in class-gutenberg-rest-comment-controller-7-2.php.

  • No N+1: when get_items() returns notes, summaries for the whole page are pre-fetched with one aggregated GROUP BY query plus one query for the current user's own reactions, regardless of how many notes come back (see prefetch_reaction_summaries()). It hooks the notes the parent query actually returns, so pagination, ordering and rest_comment_query filters all still apply.
  • Lazy-loaded reactor names: who reacted is not embedded in reaction_summary. Names are fetched the first time a pill is hovered or focused, so the initial notes load stays cheap.

On the client, useNoteReactions( noteId ) reads the summary from the cached note and toggles a reaction, folding the change into the cached summary until the refreshed notes list lands, so a quick second toggle doesn't act on stale data. A repeated click while a toggle is in flight is ignored.

The picker

The add-reaction trigger opens a Menu from @wordpress/ui, with one checkbox item per emoji (checked when you've already reacted with it). Picking an item toggles that reaction and closes the menu. The menu popup portals out of the sidebar, so it isn't clipped by the sidebar's overflow: hidden chain, and opening it keeps the note selected.

Where the trigger lives

The trigger is offered on the selected note, and not while the note is being edited or once the thread is resolved. On a note with no reactions it floats in the note's top corner, in the same column as Resolve and the actions menu, and stays faded until that note is hovered or the trigger itself is focused. A note nobody has reacted to costs no vertical space for the option, and every note keeps a safe area on that side so text never runs underneath or rewraps on selection. Once a reaction lands the row drops into the flow, and the trigger trails the pills and wraps with them. This follows @annezazu's suggestion and @fcoveram's exploration, and was first built in #82313 on the follow-up PR before moving here per @draganescu's question.

  • The reveal hangs off the note and the trigger, not the thread. The thread is tabIndex={ 0 }, so a thread-level :focus-within would hold for as long as the note is selected, and a thread-level :hover would reveal the trigger on every note in the thread at once.
  • The fade sits inside @media (hover: hover), so a touch device keeps a trigger it can actually see. It fades rather than hides, so the trigger stays in the tab order.
  • Pills stay when a note is deselected. Reactions are information about the note rather than one of its actions.
  • On a resolved thread the trigger goes away and the pills are disabled. Reopening the thread unlocks them.
  • Pill treatment follows the Notes emoji reaction Figma: your own reaction is a transparent pill with the brand outline, other people's are quiet neutral text, and the trigger is a minimal icon button using the reaction icon. All are @wordpress/ui Button/IconButton variants, with aria-pressed carrying your-reaction state for assistive tech.
  • Hovering or focusing a pill shows a tooltip with who reacted, GitHub style: "Ada, Grace, and 3 others reacted with heart".

Related

Remaining feedback from #75549

  • Performance at scale (@Mamaduka) - Consider how reactions perform with thousands of comments (e.g. make.wordpress.org). The summary is now one batched query per page of notes, but this hasn't been measured on a site that size. Comment

Already addressed

Screenshots

At rest Hovered Picker open
A note with no reactions and no visible trigger Hovering the note reveals the smiley trigger in its top corner The add-reaction menu open below the trigger, listing Heart, Celebration, Smile, Eyes and Rocket
Your reactions and someone else's Deselected
Another user's eyes reaction as a quiet pill with a tooltip naming them, between the current user's heart and rocket in the blue outline, with the trigger trailing the pills A deselected note keeps its reaction pills and hides the trigger

Testing

For testing with multiple users, use the User Switching plugin - https://wordpress.org/plugins/user-switching/

  • Create a note on a block and select it
  • Move the pointer away from the sidebar - the 😊 trigger is faded out, and the note is no taller for carrying it
  • Hover the note - the trigger fades in at the note's top right corner, in the same column as Resolve and the actions menu
  • Add a reply, then hover one note in the thread - only that note reveals its trigger
  • Tab to the trigger with the keyboard - it appears as focus lands on it
  • Click 😊 and pick an emoji from the menu - the pill appears and the trigger now trails it
  • Move the pointer away from the note - with reactions on it, the trigger stays visible at the end of the pills
  • Open the menu again - the emoji you reacted with is checked; picking it again removes your reaction
  • Switch users and add the same emoji - the count goes up instead of adding a second pill
  • Remove a reaction by clicking its pill, then add the same emoji back - verify it works (regression for the trash-counts-as-duplicate bug)
  • Add multiple different emojis to the same note
  • Hover or focus a reaction pill - the tooltip shows the reactor names
  • Verify your own reaction takes the blue outline, and someone else's stays quiet with no border or fill
  • Edit the note - the trigger is hidden while the form is open, and the note text survives the edit
  • Resolve the thread - the trigger goes away and the pills are disabled; reopen it and they work again
  • Click the post title to deselect the note - the pills stay, the trigger goes
  • Verify the menu doesn't get clipped by the pinned "All notes" sidebar's overflow
  • Keyboard: Enter on the trigger opens the menu, ArrowDown/ArrowUp navigates, Enter selects, Escape closes
  • Check the wp-admin comments page doesn't show reaction comments, and comment counts and the comments feed aren't affected by reactions
  • Trash a note that has reactions - its reactions are trashed with it
  • Run E2E tests: npm run test:e2e -- test/e2e/specs/editor/various/block-notes.spec.js -g "Emoji Reactions"
  • Run PHP tests: npm run test:unit:php:base -- --filter='WP_Test_REST_Comments_Controller_Gutenberg|Tests_Note_Reactions'

Screencast

76767-emoji-reactions-v8.mp4

AI Use

Code and description both came out of a long back and forth with 🤖 Claude Code, with plenty of steering. I will review and test.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DLZNwT2V9zTTQgAD6gF1oe

@github-actions github-actions Bot added the [Package] Editor /packages/editor label Mar 23, 2026
@adamsilverstein adamsilverstein added [Type] Enhancement A suggestion for improvement. [Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting [Status] In Progress Tracking issues with work in progress and removed [Package] Editor /packages/editor labels Mar 23, 2026
@github-actions github-actions Bot added the [Package] Editor /packages/editor label Mar 23, 2026
@github-actions

github-actions Bot commented Mar 23, 2026 •

Copy link
Copy Markdown

Size Change: +2.71 kB (+0.03%)

Total Size: 7.92 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 583 kB +2.22 kB (+0.38%)
build/styles/editor/style-rtl.css 31.7 kB +123 B (+0.39%)
build/styles/editor/style-rtl.min.css 27.2 kB +123 B (+0.45%)
build/styles/editor/style.css 31.8 kB +121 B (+0.38%)
build/styles/editor/style.min.css 27.2 kB +123 B (+0.46%)

compressed-size-action

@github-actions

github-actions Bot commented Mar 23, 2026 •

Copy link
Copy Markdown

Flaky tests detected in 4b59106.
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.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/33358611256
📝 Reported tests:

As a user I expect my navigation to use the colors I selected for it 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.62.1 (x64; ubuntu 24.04) node/20.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 2f3c77dfcc
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1788325109%7CVDQVpdmKyGDyJHhldNDkxBbMUjRgNfY7pfKdaQevpAB%7Cf13d914b590c5dcad536a59c54d71fbbb03092cab588316d1ce200012f9c2165; wp-settings-time-1=1788152342

    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

@swissspidy

Copy link
Copy Markdown
Member

Regarding unbounded requests & embedding reactions:

If embedding all the reactions on a given note is too much, we could think about caching/retrieving only the reaction count (grouped by emoji). This way we can quickly display the different reactions on a note and lazy load the individual reactions (and who gave them) after that.

@github-actions github-actions Bot added the [Package] Icons /packages/icons label Apr 4, 2026
@adamsilverstein adamsilverstein changed the title Notes: Store emoji reactions as custom comment type Notes: Add emoji reactions - stored as custom comment type Apr 29, 2026
@adamsilverstein

adamsilverstein commented Apr 29, 2026 •

Copy link
Copy Markdown
Member Author

Two open threads carried over from #75549 worth noting:

  1. Notes query is still unbounded (hooks.js:39 uses per_page: -1). reaction_summary solved the per-reaction fan-out, but Mamaduka's scale concern about thousands of notes (e.g. make.wordpress.org blogs) is still open. Probably a follow-up rather than a blocker, but flagging.
  2. Storage decision (custom comment type vs. meta) was settled across #75148 and #75549 but isn't documented here. Linking the rationale in the PR description would save a future reviewer from relitigating it.

All other feedback from #75549 has been addressed — see my comparison for details.

@adamsilverstein
adamsilverstein requested review from Mamaduka and t-hamano and removed request for spacedmonkey April 29, 2026 03:01
@adamsilverstein
adamsilverstein marked this pull request as draft April 29, 2026 03:01
@adamsilverstein

adamsilverstein commented Apr 29, 2026 •

Copy link
Copy Markdown
Member Author

@swissspidy this is what's shipping now - in case you want to double-check it matches what you had in mind:

  • Counts grouped by emoji: each note response includes a reaction_summary field — { [emojiSlug]: { count, reacted, my_reaction_id } }. Schema in class-gutenberg-rest-comment-controller-7-1.php:54, populated in prepare_item_for_response().
  • No N+1: get_items() pre-fetches summaries for the entire result set with one aggregated GROUP BY query plus one query for the current user's own reactions, regardless of how many notes are returned (see prefetch_reaction_summaries()).
  • Lazy-loaded reactor names: who reacted is not in reaction_summary — names are fetched on tooltip hover (commit 776efb9bc00), so the initial notes load stays cheap.

The unbounded per_page: -1 on the notes query itself is still open — that's a separate concern about how many notes we load at once, not how reactions are loaded per note.

@adamsilverstein

Copy link
Copy Markdown
Member Author

I'm going to look at leveraging an existing library for the emoji picker itself, something like https://github.com/liveblocks/frimousse that is well maintained, license compatible and designed to be styled/extended. This would provide a much richer experience, and we can still start with the simplified design of a small set of emoji with the full selection "behind" a (+) plus button.

@adamsilverstein

Copy link
Copy Markdown
Member Author

Here is a screencast of the current implementation in action:

react.with.emoji.picker.mp4

@adamsilverstein
adamsilverstein marked this pull request as ready for review May 8, 2026 00:13
@adamsilverstein
adamsilverstein requested review from aaronjorbin and removed request for ajitbohra, nerrad and ntwb May 8, 2026 00:13
t-hamano and others added 10 commits October 14, 2026 21:45
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Match core, which defines get_note_reaction_keys() as a private static
method on WP_REST_Comments_Controller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…om core

Co-Authored-By: Claude <noreply@anthropic.com>
@t-hamano

Copy link
Copy Markdown
Contributor

I think most of the feedback has been addressed. Here's a summary of the commits I pushed:

  1. 6e25ef8: Reactions now follow the regular comment permission model, so users who can edit a reaction can delete it. Since r64343, the edit context response includes an action-trash link, so the author-only check returned a 403 despite that link. See #discussion_r4271328897.
  2. fcc280f: Fixed the type check failure from f6eeb0b and used sentenceLabel in the "reacted with" tooltip. bec32c0 updates the e2e tests for the capitalized labels.
  3. 59677a6: Before WordPress 7.1, get_children() cached count results (fixed in r62822), so prepare_links() now calls get_comments() directly.
  4. 2b7075e: Marked every change from WordPress 7.1 in the comment controller, including new methods, with START CHANGE / END CHANGE.

Here's a summary of the remaining open comments:

  1. #discussion_r4226997739 and #discussion_r4227000380: These point out that the query filters are brittle. There may be room for improvement, although neither function has a dedicated filter, and the core PR changes their SQL directly.
  2. #discussion_r4256586449: This asks about the check that prevents creating a reaction on behalf of another user. Strictly following the comment permission model, it could be removed, but the uniqueness check and reaction_summary both key on the current user.

Finally, note that these changes haven't been backported to the core PR (#10930) yet. If I have time tomorrow, I plan to backport them to core.

I think this is ready for a final round of feedback!

@Mamaduka Mamaduka 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.

Thank you, @t-hamano!

Going to pre-approve this. We often sync changes back from core backport PRs, and I think it's much easier to review PHP code (fewer lines, etc.).

@westonruter, what do you think?

@adamsilverstein

Copy link
Copy Markdown
Member Author

Thanks @t-hamano for pushing all the updates here, appreciate the extra effort here to get this over the finish line before Beta 1. 🎉

These point out that the query filters are brittle. There may be room for improvement, although neither function has a dedicated filter, and the core PR changes their SQL directly.

I will look at this again, but don't think it should be a blocker to merging. The core side will be a little cleaner, but still messy because of the lack of a formal API.

@t-hamano

Copy link
Copy Markdown
Contributor

@adamsilverstein, I have just finished syncing the updated PHP code from this PR into the core PR. I believe both PRs are now ready to go. As long as the server-side implementation around comment permissions and security is robust, we should be able to address the client-side logic and UI after Beta 1.

@Mamaduka

Copy link
Copy Markdown
Member

As long as the server-side implementation around comment permissions and security is robust, we should be able to address the client-side logic and UI after Beta 1.

We can address most paper cuts after in beta cycle; features usually get more testing once they're merged.

@adamsilverstein

adamsilverstein commented Oct 15, 2026 •

Copy link
Copy Markdown
Member Author

I have just finished syncing the updated PHP code from this PR into the core PR. I believe both PRs are now ready to go. As long as the server-side implementation around comment permissions and security is robust, we should be able to address the client-side logic and UI after Beta 1.

Excellent! I'll give it a review pass.

@adamsilverstein

Copy link
Copy Markdown
Member Author

This tests well for me, since its approved I'm going to go ahead and get it merged so I can commit the core backport PR ahead of beta 1.

Thanks everyone for your diligent testing, review and feedback!

@jasmussen

Copy link
Copy Markdown
Contributor

Thanks for the work, Adam!

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

Labels

[Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting [Package] Editor /packages/editor [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Projects

Development

Successfully merging this pull request may close these issues.

Add emoji reactions as a first class comment type