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

Initially open dropdowns don't have event handlers attached (e.g. close on document click) #720

Closed
43081j opened this issue Apr 5, 2022 · 0 comments
Assignees
Labels
bug Things that aren't working right in the library.

Comments

@43081j
Copy link
Contributor

43081j commented Apr 5, 2022

Describe the bug

With an already open dropdown, clicking outside the container will not close it. That and all other event handlers attached in the open observer will not have run.

To Reproduce

Steps to reproduce the behavior:

      <sl-dropdown open>
        <sl-button slot="trigger" caret>Toggle</sl-button>
        <sl-menu>
          <sl-menu-item>Item 1</sl-menu-item>
        </sl-menu>
      </sl-dropdown>

Run this somewhere and click outside the dropdown, it won't close.

Click the dropdown, then reopen it, and clicking outside it will now close it.

Additional information

@watch('open', { waitUntilFirstUpdate: true })
async handleOpenChange() {

Within this observer, various event handlers are attached amongst other things.

None if this will run if the dropdown is initially open (presumably due to waitUntilFirstUpdate), meaning things like "close on document click" will not work.

@43081j 43081j added the bug Things that aren't working right in the library. label Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

No branches or pull requests

2 participants