Skip to content
Merged
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: 9 additions & 3 deletions cmdk/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -738,12 +738,18 @@ const List = React.forwardRef<HTMLDivElement, ListProps>((props, forwardedRef) =
if (height.current && ref.current) {
const el = height.current
const wrapper = ref.current
let animationFrame
const observer = new ResizeObserver(() => {
const height = el.getBoundingClientRect().height
wrapper.style.setProperty(`--cmdk-list-height`, height.toFixed(1) + 'px')
animationFrame = requestAnimationFrame(() => {
const height = el.getBoundingClientRect().height
wrapper.style.setProperty(`--cmdk-list-height`, height.toFixed(1) + 'px')
})
})
observer.observe(el)
return () => observer.unobserve(el)
return () => {
cancelAnimationFrame(animationFrame)
observer.unobserve(el)
}
}
}, [])

Expand Down