-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generic controller for closing details on outside click
Implemented a new Stimulus controller for `<details>` elements and applied it to the address form. This generic controller leverages the `useClickOutside` hook from `stimulus-use` to automatically close the `<details>` when a click is detected outside its boundaries. Co-Authored-By: Elia Schito <[email protected]>
- Loading branch information
1 parent
8b56fef
commit 3efd79f
Showing
2 changed files
with
13 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
admin/app/javascript/solidus_admin/controllers/details_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Controller } from '@hotwired/stimulus' | ||
import { useClickOutside } from 'stimulus-use' | ||
|
||
export default class extends Controller { | ||
connect() { | ||
useClickOutside(this) | ||
} | ||
|
||
clickOutside(event) { | ||
this.element.removeAttribute('open') | ||
} | ||
} |