Skip to content

fix: Comments emoji picker button issues (BLO-1199)#2769

Merged
matthewlipski merged 3 commits into
mainfrom
comments-emoji-picker-fix
Jun 2, 2026
Merged

fix: Comments emoji picker button issues (BLO-1199)#2769
matthewlipski merged 3 commits into
mainfrom
comments-emoji-picker-fix

Conversation

@matthewlipski
Copy link
Copy Markdown
Collaborator

@matthewlipski matthewlipski commented May 22, 2026

Summary

This PR fixes 2 issues with the emoji picker button in comments:

  1. The user often has to click the button multiple times to bring up the emoji picker.
  2. Clicking an emoji does nothing.

This is because the component passed to the actions prop of CommentEditor in the Comment component was inlined. This passed component contains the reactions & problematic "add reaction" button This caused it to get re-rendered every time emojiPickerOpen changed, so on each click of the "add reaction" button.

Closes #2763

Rationale

This is a bug.

Changes

  • Memoized the component passed to the CommentEditor's actions prop for each consumer.

Impact

N/A

Testing

Added e2e test.

Screenshots/Video

N/A

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

N/A

Summary by CodeRabbit

  • Refactor

    • Streamlined comment, reply, and composer action rendering for more consistent and efficient editor toolbar behavior.
  • New Features / UX

    • Comment action toolbar now more reliably shows reaction badges, an emoji picker when appropriate, and save/cancel controls while editing.
    • Reply composer displays a contextual "save reply" action only when there’s content.
  • Tests

    • Expanded end-to-end coverage for adding reactions and thread/link UI behaviors.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Inline CommentEditor action renderers were extracted into memoized components/callbacks in Comment, FloatingComposer, and Thread; CommentEditor actions prop changed to a render callback; E2E tests add emoji-reaction flow and tighten link/thread UI assertions.

Changes

Comment Actions Callback Extraction

Layer / File(s) Summary
Comment: CommentEditor actions component
packages/react/src/components/Comments/Comment.tsx
Adds CommentEditorActionsProps and a memoized CommentEditorActionsComponent; replaces inline actions JSX with this component and wires reaction/edit handlers, Components, and dict.
FloatingComposer: memoized save action component
packages/react/src/components/Comments/FloatingComposer.tsx
Adds FloatingComposerActionsComponent (memo) and a memoized onSave via useCallback; CommentEditor actions now renders this component instead of inline toolbar JSX.
Thread: reply actions component
packages/react/src/components/Comments/Thread.tsx
Adds ReplyActionsProps and ReplyActionsComponent (memo) that conditionally renders the reply save toolbar; replaces inline actions render with the extracted component.
CommentEditor: actions prop type change
packages/react/src/components/Comments/CommentEditor.tsx
Changes actions prop from FC<{ isFocused: boolean; isEmpty: boolean }> to (args: { isFocused: boolean; isEmpty: boolean }) => ReactNode and updates rendering to call the callback.
E2E tests: reactions and link assertions
tests/src/end-to-end/comments/comments.test.ts
Adds a test that adds two emoji reactions (asserts emoji picker closes and reaction count increments) and adds assertions verifying thread mark visibility and hidden formatting toolbar during link flows.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • nperez0111

Poem

🐰 I hopped through callbacks, tidy and neat,
Pulled inline actions into memoized seats.
Emojis now pop and toolbars behave,
A little rabbit cleared the comment cave. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: Comments emoji picker button issues (BLO-1199)' accurately describes the main fix—resolving emoji picker button problems through component memoization.
Description check ✅ Passed The PR description covers summary, rationale, changes, impact, testing, and checklist sections; most required template sections are present and adequately filled.
Linked Issues check ✅ Passed The PR directly addresses issue #2763 by memoizing inline action components to prevent re-renders that intercept clicks and interfere with emoji picker opening and emoji selection.
Out of Scope Changes check ✅ Passed All code changes are focused on fixing the emoji picker issues via component memoization in Comment, FloatingComposer, and Thread, plus supporting E2E tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch comments-emoji-picker-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 22, 2026

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@2769

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@2769

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@2769

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@2769

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@2769

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@2769

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@2769

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@2769

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@2769

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@2769

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@2769

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@2769

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@2769

commit: c190973

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Jun 1, 2026 2:24pm
blocknote-website Ready Ready Preview Jun 1, 2026 2:24pm

Request Review

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/src/end-to-end/comments/comments.test.ts (1)

49-49: 💤 Low value

Consider a more stable emoji selection strategy.

Using .nth(5) to select a "different" emoji is positional and fragile. If the emoji picker order changes (e.g., new categories, reordering, or emoji added earlier in the list), the test will still pass but might inadvertently select the same emoji or one that's no longer representative. Consider selecting by a known emoji data attribute (if available) or using a higher index to reduce collision risk.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/src/end-to-end/comments/comments.test.ts` at line 49, The test uses a
fragile positional selector page.locator(EMOJI_BUTTON_SELECTOR).nth(5).click(),
so change it to a more stable selection: locate the specific emoji by a stable
attribute (e.g., data-emoji or aria-label) if available, e.g., use
page.locator(`${EMOJI_BUTTON_SELECTOR}[data-emoji=":smile:"]`) or fall back to a
higher, less-colliding index (e.g., .nth(10)) to reduce breakage; update the
test to use EMOJI_BUTTON_SELECTOR combined with the known attribute or the safer
index so selection is deterministic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/src/end-to-end/comments/comments.test.ts`:
- Line 49: The test uses a fragile positional selector
page.locator(EMOJI_BUTTON_SELECTOR).nth(5).click(), so change it to a more
stable selection: locate the specific emoji by a stable attribute (e.g.,
data-emoji or aria-label) if available, e.g., use
page.locator(`${EMOJI_BUTTON_SELECTOR}[data-emoji=":smile:"]`) or fall back to a
higher, less-colliding index (e.g., .nth(10)) to reduce breakage; update the
test to use EMOJI_BUTTON_SELECTOR combined with the known attribute or the safer
index so selection is deterministic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 883e3eb7-acce-4904-bb4b-a2663c80e2f5

📥 Commits

Reviewing files that changed from the base of the PR and between d427128 and 04d4b6e.

📒 Files selected for processing (1)
  • tests/src/end-to-end/comments/comments.test.ts

@matthewlipski matthewlipski requested a review from nperez0111 May 22, 2026 18:32
Copy link
Copy Markdown
Contributor

@nperez0111 nperez0111 left a comment

Choose a reason for hiding this comment

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

Yea, I agree with Yousef's comment in the meeting. Should these be useCallbacks or should they be memoized components instead. Them being callbacks is sort of strange since they mostly are for rendering

On a React.memo you can choose the comparison function so you can make the memoization ignore anything that isn't emojiPickerOpen, or whatever makes sense as their dependencies

- Change CommentEditor actions prop from FC to render prop (function returning ReactNode)
- Extract inline action components into separate memo-wrapped components
- Remove unnecessary useCallback/useMemo wrappers around render props
- React.memo on child components handles re-render optimization
@nperez0111
Copy link
Copy Markdown
Contributor

@matthewlipski can you double check that the latest commit looks right to you? I decided to just have an agent go ahead and make the changes I wanted to see. Can you help validate that it is along the same lines as what you observed?

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/react/src/components/Comments/Comment.tsx (1)

350-363: ⚡ Quick win

Avoid forwarding unused isFocused to the memoized actions component.

CommentEditorActionsComponent doesn’t use isFocused, but passing it still invalidates React.memo when focus toggles. That adds unnecessary re-renders on the exact interaction path this PR is stabilizing.

Proposed minimal diff
-          comment.reactions.length > 0 || isEditing
-            ? ({ isFocused, isEmpty }) => (
+          comment.reactions.length > 0 || isEditing
+            ? ({ isEmpty }) => (
                 <CommentEditorActionsComponent
-                  isFocused={isFocused}
                   isEmpty={isEmpty}
                   comment={comment}
                   isEditing={isEditing}
                   threadStore={threadStore}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/react/src/components/Comments/Comment.tsx` around lines 350 - 363,
The render prop is forwarding isFocused into CommentEditorActionsComponent which
doesn't use it and causes needless memo invalidation; change the render callback
signature from ({ isFocused, isEmpty }) => ... to only accept ({ isEmpty }) =>
... and remove the isFocused prop from the props passed to
CommentEditorActionsComponent so React.memo won't be invalidated by focus
toggles (update the callback in the parent where the JSX returns
CommentEditorActionsComponent and ensure any TypeScript types/interfaces
referencing isFocused in that callback are adjusted accordingly).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/react/src/components/Comments/Comment.tsx`:
- Around line 350-363: The render prop is forwarding isFocused into
CommentEditorActionsComponent which doesn't use it and causes needless memo
invalidation; change the render callback signature from ({ isFocused, isEmpty })
=> ... to only accept ({ isEmpty }) => ... and remove the isFocused prop from
the props passed to CommentEditorActionsComponent so React.memo won't be
invalidated by focus toggles (update the callback in the parent where the JSX
returns CommentEditorActionsComponent and ensure any TypeScript types/interfaces
referencing isFocused in that callback are adjusted accordingly).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1fb7a73a-f235-40f6-8248-6ec3569fe555

📥 Commits

Reviewing files that changed from the base of the PR and between 04d4b6e and c190973.

📒 Files selected for processing (4)
  • packages/react/src/components/Comments/Comment.tsx
  • packages/react/src/components/Comments/CommentEditor.tsx
  • packages/react/src/components/Comments/FloatingComposer.tsx
  • packages/react/src/components/Comments/Thread.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/react/src/components/Comments/Thread.tsx
  • packages/react/src/components/Comments/FloatingComposer.tsx

@matthewlipski matthewlipski merged commit e6493ee into main Jun 2, 2026
28 checks passed
@matthewlipski matthewlipski deleted the comments-emoji-picker-fix branch June 2, 2026 00:39
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.

Comment sidebar - add emoji not working

2 participants