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

Ignore hide events that aren't from nodes #167

Merged
merged 1 commit into from
Aug 3, 2023
Merged

Conversation

drnic
Copy link
Contributor

@drnic drnic commented Aug 20, 2022

I was using dropdown on an input controller watching for focus events:

    <input type="text" name="search" id="search"
      placeholder="Search..."
      data-action="focus->dropdown#toggle blur->dropdown#toggle focus@window->dropdown#hide">

Without this fix, I was getting the following error when the blur event on the document triggered hide:

Error invoking action "focus@window->dropdown#hide"

TypeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.
    at extended.hide (dropdown_controller.js:134:22)
    at Binding.invokeWithEvent (stimulus.js:281:25)
    at Binding.handleEvent (stimulus.js:253:18)
    at EventListener.handleEvent (stimulus.js:31:25)

I was using `dropdown` on an `input` controller watching for `focus` events:

```html
    <input type="text" name="search" id="search"
      placeholder="Search..."
      data-action="focus->dropdown#toggle blur->dropdown#toggle focus@window->dropdown#hide">
```

Without this fix, I was getting the following error when the `blur` event on the document triggered `hide`:

```
Error invoking action "focus@window->dropdown#hide"

TypeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.
    at extended.hide (dropdown_controller.js:134:22)
    at Binding.invokeWithEvent (stimulus.js:281:25)
    at Binding.handleEvent (stimulus.js:253:18)
    at EventListener.handleEvent (stimulus.js:31:25)
```
@excid3 excid3 merged commit 6c213b0 into excid3:master Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants