JoinColony / colonyCDapp

An iteration of the Colony Dapp sporting both a fully decentralized operating mode, as well as a mode enhanced by a metadata caching layer
5 stars 14 forks source link

Fix: Dismiss lingering tooltips when the page is scrolled #3657

Open rumzledz opened 1 week ago

rumzledz commented 1 week ago

Description

TLDR: The trigger and isOpen props were clashing and led to situations whereby the tooltip still lingers even if we don't want it to. As a workaround, I had to manually detect hover states for the Tooltip's children and conditionally update the isOpen prop ✌️

Production Current Master This Branch
Production master my branch

This is how it behaves on mobile now, on this branch:

mobile-tooltip

Testing

  1. Hover on the Copy Contract Address button
  2. Click it
  3. Scroll the page
  4. Verify that its tooltip is not visible
  5. Do the same for the Share button please

Diffs

New stuff

A new hook called useOnElementScroll which executes a function when the page is scrolled:

useOnElementScroll({
  scrollableElementId: 'scrollable-element',
  callback: () => console.log('Scrolled!'),
});

I also had to slightly tweak the useCopyToClipboard hook.

Resolves #3486