Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/optimize-anchored-position.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@primer/react": patch
---

Optimized `useAnchoredPosition` hook for improved rendering performance:

- **Reduced layout thrashing**: Batches DOM reads before writes and uses `requestAnimationFrame` to coalesce multiple update triggers
- **Optimized re-renders**: Stores mutable state in refs and only triggers re-renders when position actually changes
- **ResizeObserver support**: Observes both floating and anchor elements for size changes with fallback to window resize events
- **Better late-mounting handling**: Properly detects when conditionally-rendered elements mount

The `dependencies` parameter is now deprecated and ignored - position updates are handled automatically via ResizeObserver and window resize events. The parameter is still accepted for backwards compatibility.
Loading
Loading