primitives icon indicating copy to clipboard operation
primitives copied to clipboard

Add `useResizeObserver` and standardize usage

Open Pearce-Ropion opened this issue 2 years ago • 3 comments

Resolves #2313

Description

Adds 2 new private packages:

  • @radix-ui/react-use-resize-observer
    • Extract useResizeObserver functionality from NavigationMenu and ScrollArea into reusable hook
  • @radix-ui/react-use-debounce-callback
    • Extract useDebounceCallback functionality from ScrollArea into reusable hook

Use new hooks in useSize Update instances of useResizeObserver and useDebounceCallback hooks in and NavigationMenu and ScrollArea

Package version changes affect all packages that use useSize or useResizeObserver internally

Pearce-Ropion avatar Jul 31 '23 22:07 Pearce-Ropion

I don't think we need to add a new abstraction for this, at least not now. If you find a bug in any of our current implementations please open an issue and we can address them.

chaance avatar Aug 16 '24 20:08 chaance

I don't think we need to add a new abstraction for this, at least not now. If you find a bug in any of our current implementations please open an issue and we can address them.

Could you clarify? I made this PR to resolve #2313 (linked in the PR description) which is an issue I made to describe a bug in the current implementation.

Pearce-Ropion avatar Aug 17 '24 04:08 Pearce-Ropion

@Pearce-Ropion sorry, I missed the linked issue. Reopening!

chaance avatar Aug 19 '24 14:08 chaance

Not sure if it's helpful, but I was encountering this issue from ScrollArea and managed to write a small-ish reproduction case. I'm sure it could be minimized a great deal more. The oddball Tailwind CSS classes are pulled from a larger application, but seem required for the error reproduction.

Repro: https://github.com/jasonm/dropdown-error-repro Discussion: https://github.com/vercel/next.js/discussions/74269#discussioncomment-11754678

jasonm avatar Jan 06 '25 22:01 jasonm