Skip to content

refactor: use useResizeObserver hook from usehooks-ts#2346

Merged
yujonglee merged 1 commit intomainfrom
devin/1765937682-refactor-resize-observer
Dec 17, 2025
Merged

refactor: use useResizeObserver hook from usehooks-ts#2346
yujonglee merged 1 commit intomainfrom
devin/1765937682-refactor-resize-observer

Conversation

@devin-ai-integration
Copy link
Contributor

Summary

Refactors two usages of raw ResizeObserver to use the useResizeObserver hook from usehooks-ts:

  1. useScrollState in body/index.tsx: Replaced manual ResizeObserver instantiation with the hook's onResize callback pattern. The scroll event listener remains in a separate useEffect.

  2. ProfileSection in sidebar/profile/index.tsx: Replaced a useLayoutEffect with manual ResizeObserver with the hook. The conditional logic (only update height when expanded and on main view) is preserved in the callback.

Note: A third usage in useAutoScroll (transcript hooks) was intentionally left unchanged because it observes multiple dynamic elements ([data-virtual-root]), which the hook doesn't support.

Review & Testing Checklist for Human

  • Test profile menu animation: Open the profile menu in the sidebar, verify the height animates correctly when switching between views (main → notifications → main). The original used useLayoutEffect which is synchronous; the hook uses useEffect internally which could cause timing differences.
  • Test tab scroll indicators: With many tabs open, verify the gradient fade indicators appear/disappear correctly at the edges when scrolling and when the container resizes.
  • Verify no visual flicker: Check that there's no flash of incorrect sizing when opening the profile menu.

Notes

- Refactor useScrollState in body/index.tsx to use useResizeObserver with onResize callback
- Refactor ProfileSection in sidebar/profile/index.tsx to use useResizeObserver with onResize callback
- Remove manual ResizeObserver instantiation in favor of the hook

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@netlify
Copy link

netlify bot commented Dec 17, 2025

Deploy Preview for hyprnote-storybook ready!

Name Link
🔨 Latest commit 65c2137
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote-storybook/deploys/694213314b4d05000877aa38
😎 Deploy Preview https://deploy-preview-2346--hyprnote-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Dec 17, 2025

Deploy Preview for hyprnote failed.

Name Link
🔨 Latest commit 65c2137
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/6942133149cce20008d4cf29

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

@yujonglee yujonglee merged commit 0cd3741 into main Dec 17, 2025
12 of 17 checks passed
@yujonglee yujonglee deleted the devin/1765937682-refactor-resize-observer branch December 17, 2025 03:16
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.

1 participant