-
Notifications
You must be signed in to change notification settings - Fork 424
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
Add support for @outside
global event filter
#695
base: main
Are you sure you want to change the base?
Conversation
Important: This has been built to consider the Controlled element as what should be the boundary, not sure on the best way to go about this. We could change this to be the bounds of the element that has the data-action to be more flexible. For example, these will both behave the same, only clicks that are 'fully outside' the controlled element will call <main>
<div id="outer" data-controller="a" data-action="click@outside->a#something">
<button type="button" id="inner-button">outer<button>
<div id="inner" data-action="click@outside->a#something">
<button type="button" id="inner-button">inner</button>
</div>
</div>
<button type="button">fully outside</button>
</main> This may not be intuitive, so happy to adjust the PR so that it works based on the contains being compared against the element with the data-action. |
That would feel more natural to me having the outside being compared to the element with the data action and not the controller by itself. |
db64cb5
to
7069d82
Compare
@adrienpoly yeah, I had a think about this and agree it would be pretty confusing, I have now changed the behaviour and updated unit tests. When you set the data-action, that will be the 'contains' element, irrespective of the controlled element. |
7069d82
to
f919a43
Compare
Not sure why it's failing, I don't think it's related to this PR.
|
f919a43
to
67b7df1
Compare
Rebased |
67b7df1
to
1460534
Compare
Rebased |
Nice work. I'd love to see this being merged! I was about to attempt implementing this after adding the same |
- When using `@outside`, it will behave the same as @document but only trigger the action if the event was triggered from outside the element with the attached action - Closes hotwired#656
1460534
to
46bbce1
Compare
Just rebased |
This feature is absolutely needed. I use |
Exactly |
@outside
, it will behave the same as @document but only trigger the action if the event was triggered from outside the controlled element.