Joystream / pioneer

Governance app for Joystream DAO
https://pioneerapp.xyz/
GNU General Public License v3.0
44 stars 70 forks source link

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

Open dmtrjsg opened 1 year ago

dmtrjsg commented 1 year ago

 Context

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

 Scope

dmtrjsg commented 1 year ago

@traumschule pls feel free to assign

WRadoslaw commented 1 year ago

@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])