pioneer icon indicating copy to clipboard operation
pioneer copied to clipboard

Hide tooltip on locked accounts as soon as contents of scroll bar (accounts) start to get scrolled

Open dmtrjsg opened this issue 2 years ago • 2 comments

## Context

Tooltip is flipping when accounts are scrolled Screenshot 2022-11-24 at 17.02.06.png

## Scope

  • [ ] Close tooltip as soon as user starts scrolling the accounts up or down

dmtrjsg avatar Nov 24 '22 13:11 dmtrjsg

@traumschule pls feel free to assign

dmtrjsg avatar Nov 24 '22 13:11 dmtrjsg

@oleksanderkorn This might fix the issue

const [isDetached, setIsDetached] = useState(false)

  const { styles, attributes, state } = usePopper(referenceElementRef, popperElementRef, {
    placement: isDetached ? 'top-start' : 'bottom-start',
    modifiers: [
      {
        name: 'offset',
        options: {
          offset: offset ?? [0, 0],
        },
      },
    ],
  })

  useEffect(() => {
    if (referenceElementRef && boundaryElement) {
      const refBox = referenceElementRef.getBoundingClientRect()
      const boundaryBox = boundaryElement.getBoundingClientRect()

      setIsDetached(boundaryBox.bottom + boundaryBox.y < refBox.bottom + refBox.y)
    }
  }, [!state, !boundaryElement])

WRadoslaw avatar Nov 24 '22 13:11 WRadoslaw