Skip to content

Notes: Add a filter for the limited preset emoji reaction list - #84200

Open
adamsilverstein wants to merge 210 commits into
trunkfrom
add/notes-reaction-emoji-filter
Open

adamsilverstein wants to merge 210 commits into
trunkfrom
add/notes-reaction-emoji-filter

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Fixes #84199.

Follow up to #76767, which ships a fixed set of seven reaction emoji in WordPress 7.2. This brings back a way for sites to change that list, targeted at 7.3, as a follow-up we can review on its own, the same way #84043 does for the full picker.

Core backport: WordPress/wordpress-develop#14132 (Trac https://core.trac.wordpress.org/ticket/66276)

What?

Claude wrote the code, summary below:

Adds the wp_note_reaction_emojis filter. Each entry is a hex key and a label, so a site can add emoji, remove them, or turn adding reactions off with an empty list:

add_filter( 'wp_note_reaction_emojis', function ( $emojis ) {
	// Remove the default "eyes" emoji.
	$emojis = array_filter(
		$emojis,
		function ( $emoji ) {
			return '1f440' !== $emoji['hex_key'];
		}
	);

	// Add a unicorn.
	$emojis[] = array( 'hex_key' => '1f984', 'label' => 'unicorn' );

	return $emojis;
} );

Why?

The filter was in an earlier version of #76767 and got dropped to keep that first iteration small (see the review there and #83538 (review)). Sites still need a way to shape the list, and keeping it here lets us talk through the rendering concern without holding up #76767.

How?

  • Server: the code lives in lib/compat/wordpress-7.3/note-reactions.php. gutenberg_get_note_reaction_emojis() runs the filter and normalizes each key the way reactions are stored (lowercase, padded to four digits, U+FE0F dropped). Malformed entries, invalid code points, empty labels and duplicate keys are dropped. gutenberg_get_note_reaction_keys() now reads from that list, so the REST API accepts exactly the filtered set.
  • Editor: the list is passed as the noteReactionEmojis editor setting. useReactionEmojis() reads it from the editor store and offers no emoji when it is missing, since the accepted emoji are then unknown. The menu renders each emoji from its hex key, putting U+FE0F back after each code point that defaults to text, so keycaps and flags come out fully qualified.
  • The picker is a grid of up to seven columns that scrolls after five rows, so a long list stays on screen. The default list keeps its single row.
  • An empty list hides the add-reaction trigger. A pill for an emoji the site no longer offers stays visible, rendered from its hex key, and can only remove the user's own reaction (the server rejects adding it).
  • Entries use hex_key in PHP, snake_case like the REST fields. The editor maps it to its own hexKey when it reads the setting.
  • The filter docs note that the editor renders emoji as text, so newer emoji and flags may not render everywhere. Picking emoji that work for a site's users is left to the site for now.

Screenshots

Captured with the e2e test plugin (packages/e2e-tests/plugins/note-reaction-emojis.php), which applies the filter above.

Default list Filtered: eyes removed, unicorn added Reacting with the added unicorn
Add reaction menu with the seven default emoji, including eyes Add reaction menu with the eyes emoji removed and a unicorn added at the end Note showing a unicorn reaction pill with a count of 1
More screenshots: 10, 20 and 100 added emoji

The picker lays emoji out in rows of up to seven, so the default list stays on one row, and scrolls after five rows.

10 added 20 added 100 added
With 10 added emoji, the reaction menu wraps into three rows of seven under the trigger With 20 added emoji, the reaction menu wraps into four rows of seven With 100 added emoji, the reaction menu shows five rows and scrolls

Testing Instructions

Test in WordPress Playground

  1. Add the filter from above, eg. in a mu-plugin. It removes the default eyes emoji and adds a unicorn.
  2. Add a note to a block and open "Add reaction". The menu offers unicorn and no eyes.
  3. React with the unicorn. The pill shows 🦄 and its tooltip says "unicorn".
  4. Change the filter to __return_empty_array. The add-reaction trigger is gone, and the unicorn pill is still there; clicking it removes your reaction.

Tested locally:

  • PHPUnit: Tests_Note_Reaction_Emojis and WP_Test_REST_Comments_Controller_Gutenberg - 97 pass.
  • Vitest: the collab-sidebar/reactions tests and the private selectors - 39 pass.
  • PHPStan, PHPCS, ESLint and typecheck are clean.
  • e2e: not re-run locally since the last round, relying on CI for the "Filtered emoji list" test.

Open questions

AI Use

Claude Code did the typing on both the code and this description, I did the asking. I will review and test.

adamsilverstein and others added 30 commits June 30, 2026 12:30
Introduce a new component that displays a horizontal row of emoji
buttons for adding reactions to notes. Features include:

- Curated emoji set: 👍 👎 ❤️ 🎉 😄 😕 👀 🚀
- Keyboard navigation with arrow keys, Home, and End
- Accessible with role="listbox" and role="option"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Introduce a component that displays current reactions with counts
as pill-shaped buttons. Features include:

- Shows reaction counts for each emoji
- Highlights user's own reactions with distinct styling
- Click to toggle (add/remove) reaction
- "+" button opens emoji picker dropdown

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Introduce a popover component that shows who reacted and when.
Features include:

- Displays reactions grouped by emoji
- Shows user avatars and names
- Uses humanTimeDiff() for relative timestamps (e.g., "3 days ago")
- Fetches user data for all reactors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extend the useBlockCommentsActions hook with three new functions:

- onAddReaction: Add a reaction to a comment
- onRemoveReaction: Remove user's reaction from a comment
- onToggleReaction: Toggle reaction (add if not present, remove if present)

Reactions are stored in comment meta._wp_reactions with structure:
{ emoji: [{ userId, timestamp }] }

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add SCSS styles for:

- Reactions container with flexbox layout
- Pill-shaped reaction buttons with active state
- Add reaction button with dashed border
- Emoji picker dropdown
- Reaction details popover with user avatars

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…yling

Replace the plus icon with a Google Docs-inspired smiley face SVG, change
focusOnMount to 'firstElement' so the emoji picker captures focus and
prevents the note from collapsing, and restyle the button to be perfectly
round with a clean white background that appears on hover.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the "Add reaction" smiley button from below the note content to the
upper-right header area alongside the resolve and actions buttons. Also
register _wp_reactions as comment meta in PHP so the REST API accepts it,
and fix the 500 error caused by spreading all comment meta (including
potentially invalid _wp_note_status) when saving reactions.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Add variant="tertiary" to the reaction pill Button components so the
WordPress default dark button styling doesn't override the custom
light gray background.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
The Button component automatically adds the is-pressed class when
aria-pressed is true, which sets a dark background (#1E1E1E). Override
with matching specificity to keep the light blue active state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Increase height to 32px, use equal padding on all sides, and reduce
gap between emoji and count to bring the aspect ratio closer to 1:1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The reactions meta registration is a new feature targeting
WordPress 7.0, not a 6.9 backport. Move it to its own file
in lib/compat/wordpress-7.0/ per reviewer feedback.
The editor assumes users are logged in by default, so these
guards are redundant. Matches the pattern used by other
collab sidebar actions.
Reactions update comment metadata without adding, removing,
or resizing comments, so reflowing is unnecessary.
Replace individual getUser() calls with a single getUsers()
request using include, context: view, and _fields to reduce
API calls and support low-capability users.
Negative reactions are better expressed as comments in a
collaborative editing context. The thinking emoji provides
a constructive "I need to consider this" signal instead.
The horizontal layout caused emojis to overflow and get
cut off in the sidebar popover.
Start conservatively with ❤️ 🎉 😄 👀 🚀 to avoid
skin-tone concerns and keep the picker compact. More
reactions can be added later.
Aligns with the existing _wp_note_status meta key naming
convention. Both meta keys are used exclusively for block
comments (notes), so using the _wp_note_ prefix for both
makes the naming more consistent and clearly indicates
these are note-specific features.
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
The useSelect subscription for the current user ID was
running for all notes in CommentBoard. Since ReactionDisplay
only renders when a note is selected, moving the selector
there avoids unnecessary subscriptions.
Show GitHub-style tooltips on reaction buttons instead of
requiring a menu action to open a details popover. The
tooltip displays who reacted (e.g. "Alice and Bob reacted
with Heart emoji"), providing quicker access to this info.
The setting is editor-specific, so read it from the editor store instead
of passing it through the WP-agnostic block-editor settings. When it is
missing, offer no emoji rather than client-side defaults the server may
have filtered out and would reject.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017FGp5zYv14MKoTuh3RFuWi
@adamsilverstein adamsilverstein changed the title Notes: Add a filter for the emoji reaction list Notes: Add a filter for the limited preset emoji reaction list Oct 8, 2026
adamsilverstein and others added 2 commits October 8, 2026 23:07
The editor read the `noteReactionEmojis` setting straight from
getEditorSettings(), which made the setting key a de facto public API.
Route it through a private `getNoteReactionEmojis` selector and mark the
setting internal, so the list can move to another data source later
without breaking anyone. The `wp_note_reaction_emojis` filter stays the
public extension point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UfTH9DtSqxSHGAAgE2NDVM
…dditional-comment-type' into add/notes-reaction-emoji-filter

# Conflicts:
#	lib/compat/wordpress-7.2/note-reactions.php
Mamaduka and others added 7 commits October 9, 2026 13:41
- useNoteReactions( noteId ): useEntityProp-style [ summary, toggle ].
- Drop redundant summary refetch; notes list refetch already brings it.
- Merge pills and picker into NoteReactions.
- Reactor names tied to summary identity; drop module cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the hand-rolled page walk and names cache with a getEntityRecords
select gated on pill hover/focus. core-data caches across remounts and
invalidates on comment writes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/notes-reaction-emoji-filter

The parent folded ReactionDisplay and AddReactionButton into
NoteReactions, so the filtered emoji list moves there: the picker
lists useReactionEmojis(), hides when the list is empty, and a pill
for an emoji no longer offered renders from its hex key and only
allows removing the user's own reaction.

Claude-Session: https://claude.ai/code/session_01RmMwj4CN9cF8b1Sx58Pvik
Mapping the shorter emojis name lets Prettier collapse the callback.

Claude-Session: https://claude.ai/code/session_01RmMwj4CN9cF8b1Sx58Pvik
The ReactionDisplay test that covered removal-only pills went away
with the component, so test the same behavior on NoteReactions, plus
hiding the picker when the site offers no emoji.

Claude-Session: https://claude.ai/code/session_01RmMwj4CN9cF8b1Sx58Pvik
Base automatically changed from add-notes-emoji-reactions-try-addditional-comment-type to trunk October 16, 2026 23:37
The filter is milestoned for 7.3 and has its own Core PR (wpd #14132), so move its functions to the 7.3 compat directory and give it its own backport changelog entry. Add return types and the list shape to the docblocks, as asked in review, so PHPStan checks callers against it.
Keys drop U+FE0F, and it only went back after a single code point, so a keycap or flag added through the filter rendered unqualified, and emoji that already default to emoji presentation gained a stray selector. Restore it after each code point that defaults to text, matching the picker in #83538.
The filter is a PHP API, so its array keys follow core's snake_case like the REST fields do. The editor maps hex_key to its own hexKey when it reads the setting.
@adamsilverstein

Copy link
Copy Markdown
Member Author

Thanks for the review @westonruter!

The picker was a single row, so a filtered list of 20 or more emoji ran
across the canvas and, at 100, off screen where most emoji could not be
clicked. Lay it out as a grid of up to seven columns, which keeps the
default list on one row, and scroll after five rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018vwYjSvYqQEKwGQupRKktQ
adamsilverstein added a commit that referenced this pull request Nov 11, 2026
WordPress 7.2 ships the fixed list of reactions, so the filters move to
the 7.3 compat directory. Named emoji entries now use `hex_key`, the
same shape as the `wp_note_reaction_emojis` filter in #84200, and the
key normalizer matches the one that PR adds: it rejects values that are
not code points and handles over-padded ones. Functions gain return
types and full array shapes, following the review of #84200.

Claude-Session: https://claude.ai/code/session_018vwYjSFEhWEs8GA798tZbi
@adamsilverstein

Copy link
Copy Markdown
Member Author

I added a more screenshots in the description and made sure the selector works even if 100 emoji are added.

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

[Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting [Package] E2E Tests /packages/e2e-tests [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notes: Let developers filter the emoji reaction list

3 participants