Skip to content

virtualized React Select (select_list) — channel field list rows vanish on scroll #5340

Open

Description

@robinsowell

Weird one- came in via email and confirmed.

Have a lot of custom fields- more than 100, which is where virtualization kicks in. Go edit a channel, go to the field select, start scrolling down. And eventually, they just start to disappear and you don't see them.

Image

Our very clever user also provides a fix, but I'll get someone with better frontend chops to implement!

Rows scroll out and disappear; past ~halfway the whole list vanishes.
Console: TypeError: Cannot read properties of undefined (reading 'instructions') at getVirtualItemHeight (VirtualizedItemList.getOffsetTop → render).
Root cause — themes/ee/asset/javascript/src/components/select_list.es6, VirtualizedItemList:
The component uses two different height models. getVisibleRange() computes startIndex/visibleCount from a fixed 40px per row (Math.floor(scrollTop / 40)), but getOffsetTop()/getTotalHeight() position and size the list using the variable getVirtualItemHeight() (40/60/70/35 depending on instructions/toggles/isSection). Since real rows are taller than 40, offsetTop grows faster than scrollTop, so the absolutely-positioned window drifts below the viewport as you scroll → rows vanish. The same over-estimated indices push items[i] out of range, handing undefined to getVirtualItemHeight, which reads item.instructions → the TypeError.

Fix: compute the visible range by walking the same variable heights, use the configured virtualizationHeight, and guard against an undefined item.

 function getVirtualItemHeight(item) {

  •  if (!item) return 40
       let height = 40
       if (item.instructions) { height += 20 }
       if (item.toggles && Object.keys(item.toggles).length > 0) { height += 10 }
       if (item.isSection) { height = 35 }
       return height
     }

 getVisibleRange() {

  •  const scrollTop = this.state.scrollTop
  •  const containerHeight = 400          // Default container height
  •  const itemHeight = 40                // Base item height
  •  const overscan = 10
  •  const startIndex = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan)
  •  const visibleCount = Math.ceil(containerHeight / itemHeight) + overscan * 2
  •  const endIndex = Math.min(this.props.items.length - 1, startIndex + visibleCount)
  •  return { startIndex, endIndex }
  •  const scrollTop = this.state.scrollTop
  •  const containerHeight = this.props.virtualizationHeight || 400
  •  const overscan = 10
  •  const items = this.props.items
  •  // Visible range must use the SAME variable heights as getOffsetTop()/getTotalHeight().
  •  // The old fixed-40px math drifted out of sync with the variable-height offsets, so the
  •  // rendered window slid below the viewport and rows vanished on scroll.
  •  let startIndex = 0, cumulative = 0
  •  while (startIndex < items.length) {
  •    const h = getVirtualItemHeight(items[startIndex])
  •    if (cumulative + h > scrollTop) break
  •    cumulative += h
  •    startIndex++
  •  }
  •  let endIndex = startIndex, visibleHeight = 0
  •  while (endIndex < items.length && visibleHeight < containerHeight) {
  •    visibleHeight += getVirtualItemHeight(items[endIndex])
  •    endIndex++
  •  }
  •  startIndex = Math.max(0, startIndex - overscan)
  •  endIndex = Math.min(items.length - 1, endIndex + overscan)
  •  return { startIndex, endIndex }
     }

Note: patch the source select_list.es6 (compiles to compressed/components/select_list.js). getVisibleRange is now O(n) per scroll — same complexity class as the existing getOffsetTop/getTotalHeight; a memoized prefix-sum of heights would reduce all three if you want it cheaper for very large lists. Verified on a production 7.5.21 install: list scrolls correctly, scrollbar length correct, no vanishing, console error gone.

Activity

  1. added
    Bug: Accepted
    on Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: Accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions