Skip to content

Changed comments UI listener option typing#28733

Open
PedroMarianoAlmeida wants to merge 2 commits into
TryGhost:mainfrom
PedroMarianoAlmeida:comments-ui-listener-option-typing
Open

Changed comments UI listener option typing#28733
PedroMarianoAlmeida wants to merge 2 commits into
TryGhost:mainfrom
PedroMarianoAlmeida:comments-ui-listener-option-typing

Conversation

@PedroMarianoAlmeida

@PedroMarianoAlmeida PedroMarianoAlmeida commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Replaced the any casts on keydown removeEventListener calls in comments-ui with EventListenerOptions.

The runtime behavior is intended to stay the same. These listeners are added with {passive: true}, and the cleanup calls already passed the same options object when removing them. The previous code used as any because removeEventListener is typed with EventListenerOptions, while passive belongs to AddEventListenerOptions.

An alternative would be to remove {passive: true} from the removeEventListener calls entirely, because listener removal only depends on the event type, listener function, and capture flag. I avoided that here to keep the existing cleanup shape unchanged and make this PR a narrow typing cleanup.

Verification:

PATH=/Users/pedroalmeida/.nvm/versions/node/v22.13.1/bin:$PATH CI=true pnpm --filter @tryghost/comments-ui exec tsc --noEmit

This currently fails on existing package-wide comments-ui TypeScript issues, mainly missing React declarations and implicit any errors. The updated removeEventListener lines are not implicated in the failure.

  • I've read and followed the Contributor Guide
  • I've explained my change
  • I've written an automated test to prove my change works

Replaced keydown removeEventListener any casts with EventListenerOptions casts.
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 47dec17f-28f5-4283-abdf-14511ad38361

📥 Commits

Reviewing files that changed from the base of the PR and between 027b353 and 7c524d6.

📒 Files selected for processing (5)
  • apps/comments-ui/src/components/content/context-menus/comment-context-menu.tsx
  • apps/comments-ui/src/components/content/forms/form.tsx
  • apps/comments-ui/src/components/content/forms/main-form.tsx
  • apps/comments-ui/src/components/content/forms/sorting-form.tsx
  • apps/comments-ui/src/components/popups/generic-popup.tsx

Walkthrough

Across five components in comments-ui (comment-context-menu.tsx, form.tsx, main-form.tsx, sorting-form.tsx, and generic-popup.tsx), the useEffect cleanup logic for event listeners is simplified by removing the { passive: true } options argument from removeEventListener calls. The listeners themselves and their event handling logic remain unchanged; only the cleanup removal calls are modified.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: updating listener option typing in the comments UI component by removing any casts from removeEventListener calls.
Description check ✅ Passed The description is directly related to the changeset, explaining the typing changes to removeEventListener calls and why the modifications were made.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

…mments-ui

passive is not a valid removeEventListener option (EventListenerOptions
only accepts capture) and is ignored on removal. The paired
addEventListener calls all use {passive: true} with no capture, so the
matching removals only need capture=false, which is the default. Dropping
the third argument entirely removes the need for the as any / as
EventListenerOptions casts across all 8 listener removals.

@9larsons 9larsons left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks 👍 .

@9larsons 9larsons enabled auto-merge (squash) June 23, 2026 18:40
@nx-cloud

nx-cloud Bot commented Jun 23, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 7c524d6

Command Status Duration Result
nx build @tryghost/announcement-bar ✅ Succeeded <1s View ↗
nx build @tryghost/activitypub ✅ Succeeded 2s View ↗
nx build @tryghost/sodo-search ✅ Succeeded <1s View ↗
nx build @tryghost/signup-form ✅ Succeeded <1s View ↗
nx build @tryghost/comments-ui ✅ Succeeded <1s View ↗
nx build @tryghost/portal ✅ Succeeded <1s View ↗
nx build @tryghost/admin-toolbar ✅ Succeeded <1s View ↗
nx run @tryghost/admin:build ✅ Succeeded 19s View ↗
Additional runs (6) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-23 18:44:34 UTC

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.

2 participants