Skip to content

CopilotStep Position Not Updating After Scrolling FlatList on Next Step #346

@grkemtneri

Description

@grkemtneri

I'm using Copilot inside a FlatList. When a CopilotStep item is not currently visible (e.g. near the bottom of the list) and I call next() to move to the next step, the FlatList scrolls to bring the step into view — but the CopilotStep does not update its position.

As a result, the tooltip appears at the old location, not aligned with the actual step.

It seems like the position of the CopilotStep is not recalculated after the FlatList has finished scrolling. Is there a way to force Copilot to re-measure the step’s position after the scroll completes?

  useEffect(() => {
    const listener = (step) => {
      setTimeout(() => {
        if (step?.wrapperRef?.current && screenRef.current) {
          step.wrapperRef.current.measure((x, y, width, height, pageX, pageY) => {
            setTimeout(() => {
              if (step.name === COPILOT_STEPS.PromotionMenu) {
                screenRef.current.scrollTo(pageX - 16, true)
              }
            }, 300)
          })
        }
      }, 300)
    }

    copilotEvents.on('stepChange', listener)

    return () => {
      copilotEvents.off('stepChange', listener)
    }
  }, [])

can you help me ? @mohebifar

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions