Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(replay): remove redundant per-row ResizeObserver in inspector list (#85788)

HaynesPostHog0628f890ef24
diff --git a/frontend/src/scenes/session-recordings/player/inspector/components/PlayerInspectorListItem.tsx b/frontend/src/scenes/session-recordings/player/inspector/components/PlayerInspectorListItem.tsx
index 944e8d27a6e8..81143447c7c0 100644
--- a/frontend/src/scenes/session-recordings/player/inspector/components/PlayerInspectorListItem.tsx
+++ b/frontend/src/scenes/session-recordings/player/inspector/components/PlayerInspectorListItem.tsx
@@ -1,8 +1,6 @@
import clsx from 'clsx'
import { useActions, useValues } from 'kea'
-import { FunctionComponent, isValidElement, memo, useEffect, useRef } from 'react'
-import { useDebouncedCallback } from 'use-debounce'
-import useResizeObserver from 'use-resize-observer'
+import { FunctionComponent, isValidElement, memo, useRef } from 'react'
import {
BaseIcon,
@@ -61,8 +59,6 @@ import { ItemAppState, ItemAppStateDetail, ItemConsoleLog, ItemConsoleLogDetail
import { ItemDoctor, ItemDoctorDetail } from './ItemDoctor'
import { ItemEvent, ItemEventDetail, ItemEventMenu } from './ItemEvent'
-const PLAYER_INSPECTOR_LIST_ITEM_MARGIN = 1
-
interface IconAndDescription {
Icon: FunctionComponent | undefined
tooltip: string | undefined
@@ -424,17 +420,16 @@ const ListItemDetail = memo(function ListItemDetail({
export const PlayerInspectorListItem = memo(function PlayerInspectorListItem({
item,
index,
- onLayout,
groupCount,
groupedItems,
}: {
item: InspectorListItem
index: number
- onLayout?: (layout: { width: number; height: number }) => void
groupCount?: number
groupedItems?: InspectorListItem[]
}): JSX.Element {
const hoverRef = useRef<HTMLDivElement>(null)
+ const ref = useRef<HTMLDivElement>(null)
const { logicProps } = useValues(sessionRecordingPlayerLogic)
@@ -442,36 +437,6 @@ export const PlayerInspectorListItem = memo(function PlayerInspectorListItem({
const isExpanded = expandedItems.includes(index)
- const onLayoutDebounced = useDebouncedCallback(onLayout ?? (() => {}), 500)
- const { ref, width, height } = useResizeObserver({})
-
- const totalHeight = height ? height + PLAYER_INSPECTOR_LIST_ITEM_MARGIN : height
-
- // Height changes should lay out immediately but width ones (browser resize can be much slower)
- useEffect(
- () => {
- if (!onLayout || !width || !totalHeight) {
- return
- }
- onLayoutDebounced({ width, height: totalHeight })
- },
- // purposefully only triggering on width
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [width]
- )
-
- useEffect(
- () => {
- if (!onLayout || !width || !totalHeight) {
- return
- }
- onLayout({ width, height: totalHeight })
- },
- // purposefully only triggering on total height
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [totalHeight]
- )
-
const isHovering = useIsHovering(hoverRef)
return (