mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 22:34:47 +00:00
Allow event propagation to fix turbo frame update (#575)
* Allow event propagation to fix turbo frame update * Add setting to dropdown to manage close when open and clicking on it
This commit is contained in:
@@ -3,6 +3,7 @@ import { Controller } from "@hotwired/stimulus"
|
||||
// Connects to data-controller="dropdown"
|
||||
export default class extends Controller {
|
||||
static targets = ["menu"]
|
||||
static values = { closeOnClick: { type: Boolean, default: true } }
|
||||
|
||||
toggleMenu = (e) => {
|
||||
e.stopPropagation(); // Prevent event from closing the menu immediately
|
||||
@@ -24,7 +25,7 @@ export default class extends Controller {
|
||||
}
|
||||
|
||||
onDocumentClick = (e) => {
|
||||
if (this.menuTarget.contains(e.target)) {
|
||||
if (this.menuTarget.contains(e.target) && !this.closeOnClickValue ) {
|
||||
// user has clicked inside of the dropdown
|
||||
e.stopPropagation();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user