Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Popover] addEventListener null #100

Closed
benjamincanac opened this issue Oct 21, 2022 — with Volta.net · 1 comment · Fixed by #105
Closed

[Popover] addEventListener null #100

benjamincanac opened this issue Oct 21, 2022 — with Volta.net · 1 comment · Fixed by #105
Assignees
Labels
bug Something isn't working

Comments

Copy link
Member

CleanShot 2022-10-21 at 13.51.26@2x.png

@benjamincanac benjamincanac added the bug Something isn't working label Oct 21, 2022 — with Volta.net
Copy link
Contributor

smarroufin commented Oct 25, 2022

It refers to the code below. This is hacky and will stay that way since we have no other choice.
We consider 200ms enough to have everything mounted and introspect the headlessui component. In a few cases, this amount of time may not be enough.

It crashes on popoverApi.value.button.addEventListener. So I will only secure it with null-checks ? and that will be fine.

  setTimeout(() => {
    const popoverProvides = trigger.value?.$.provides
    if (!popoverProvides) {
      return
    }
    const popoverProvidesSymbols = Object.getOwnPropertySymbols(popoverProvides)
    popoverApi.value = popoverProvidesSymbols.length && popoverProvides[popoverProvidesSymbols[0]]
    // stop trigger click propagation on hover
    popoverApi.value.button.addEventListener('click', (e: Event) => {
      if (props.mode === 'hover') {
        e.stopPropagation()
      }
    }, true)
  }, 200)

EDIT:
I've done it right in Dropdown but not in Popover. My bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants