Skip to content

Comments

feat: DH-21211: Adding window listener hook#2620

Merged
jnumainville merged 4 commits intodeephaven:mainfrom
jnumainville:21211_useWindowListener
Feb 4, 2026
Merged

feat: DH-21211: Adding window listener hook#2620
jnumainville merged 4 commits intodeephaven:mainfrom
jnumainville:21211_useWindowListener

Conversation

@jnumainville
Copy link
Contributor

Adding window listener hook as mentioned in https://github.com/deephaven-ent/iris/pull/3926

@jnumainville jnumainville self-assigned this Feb 2, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a reusable React hook useWindowListener for managing window event listeners with automatic cleanup. The hook simplifies the common pattern of adding and removing event listeners in React components by handling the lifecycle management automatically.

Changes:

  • New useWindowListener hook that accepts single or multiple event types, a callback function, and optional listener options
  • Comprehensive test suite covering event registration/cleanup, dependency updates, and edge cases
  • Hook implementation uses useMemo for event array normalization and useEffect for listener lifecycle management

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/react-hooks/src/useWindowListener.ts Implements the hook with support for single/multiple events, callback handling, and options forwarding
packages/react-hooks/src/useWindowListener.test.ts Provides extensive test coverage for various scenarios including unmounting, dependency changes, and event dispatching

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mofojed
mofojed previously approved these changes Feb 3, 2026
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.52%. Comparing base (24f4580) to head (ed3a44d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2620      +/-   ##
==========================================
- Coverage   49.76%   49.52%   -0.25%     
==========================================
  Files         773      774       +1     
  Lines       43759    43767       +8     
  Branches    11072    11256     +184     
==========================================
- Hits        21777    21674     -103     
- Misses      21964    22047      +83     
- Partials       18       46      +28     
Flag Coverage Δ
unit 49.52% <100.00%> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jnumainville jnumainville requested a review from mofojed February 3, 2026 22:12
@jnumainville jnumainville enabled auto-merge (squash) February 3, 2026 22:12
@jnumainville jnumainville merged commit 295322f into deephaven:main Feb 4, 2026
10 of 11 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants