app/javascript/controllers/ui/dialog_controller.js in shadcn-ui-0.0.1 vs app/javascript/controllers/ui/dialog_controller.js in shadcn-ui-0.0.2
- old
+ new
@@ -1,10 +1,10 @@
// Inspired by https://github.com/kanety/stimulus-dialog
import { Controller } from "@hotwired/stimulus";
import "@kanety/stimulus-static-actions";
-export default class extends Controller {
+export default class UIDialog extends Controller {
static targets = ["dialog", "modal", "focus", "drag", "backdrop", "closeButton"];
static actions = [
["element", "keydown@window->closeByKey"],
["modal", "click->closeByModal"],
["closeButton", "click->close"],
@@ -62,9 +62,11 @@
this.toggleClass(false);
this.dispatch("closed", { detail: { target: target } });
}
+ // Refactor Me
+ // This needs to be combined with the toggle method in sheet_controller
toggleClass(visible) {
if (visible) {
this.dialogTarget.classList.remove("hidden");
this.dialogTarget.dataset.state = "open";
if (this.hasBackdropTarget) {