ycs77 / headlessui-float

Easily use Headless UI with Floating UI to position floating elements.
https://headlessui-float.vercel.app
MIT License
344 stars 11 forks source link

Issue when using custom component as ref #23

Closed DennisOng closed 1 year ago

DennisOng commented 1 year ago

Use Version Use version when bugs appear:

Describe the bug FloatingUI is not working when a custom component is used as ref, eg:

// Not working
        <PopoverButton as="template">
            <BaseButton>Button </BaseButton>
        </PopoverButton>

// Works
        <PopoverButton as="template">
             <button>Button</button>
        </PopoverButton>

To Reproduce Please provide a minimal working example (like github repo, codesandbox, stackblitz...), and steps to reproduce the behavior:

  1. Go to 'this StackBlitz'
  2. Click on the first button. It works well
  3. Click on the second button.
  4. See console error. Also floating UI is not positioning correctly
    TypeError: element.getBoundingClientRect is not a function
    at getBoundingClientRect (floating-ui.dom.esm.js:102:30)

Screenshots

Capture

Expected behavior Button 2 should work exactly as button 1

PS: Nice work on this lib! Have spent way too much time trying to roll my own, switching over currently. Thanks for the work.

ycs77 commented 1 year ago

Fixed in v0.10.0

DennisOng commented 1 year ago

Thanks again for your work! Just tested with the latest release - the issue has been resolved