@radioactive-labs/plutonium 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@ import AttachmentPreviewController from "./attachment_preview_controller.js"
18
18
  import AttachmentPreviewContainerController from "./attachment_preview_container_controller.js"
19
19
  import SidebarController from "./sidebar_controller.js"
20
20
  import PasswordVisibilityController from "./password_visibility_controller.js"
21
+ import RemoteModalController from "./remote_modal_controller.js"
21
22
 
22
23
  export default function (application) {
23
24
  // Register controllers here
@@ -40,4 +41,5 @@ export default function (application) {
40
41
  application.register("attachment-input", AttachmentInputController)
41
42
  application.register("attachment-preview", AttachmentPreviewController)
42
43
  application.register("attachment-preview-container", AttachmentPreviewContainerController)
44
+ application.register("remote-modal", RemoteModalController)
43
45
  }
@@ -0,0 +1,24 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+
3
+ // Connects to data-controller="remote-modal"
4
+ export default class extends Controller {
5
+ connect() {
6
+ // Store original scroll position
7
+ this.originalScrollPosition = window.scrollY;
8
+
9
+ // Show the modal
10
+ this.element.showModal();
11
+ // Add close event listener
12
+ this.element.addEventListener('close', this.handleClose.bind(this));
13
+ }
14
+
15
+ disconnect() {
16
+ // Clean up event listener when controller is disconnected
17
+ this.element.removeEventListener('close', this.handleClose);
18
+ }
19
+
20
+ handleClose() {
21
+ // Restore the original scroll position after dialog closes
22
+ window.scrollTo(0, this.originalScrollPosition);
23
+ }
24
+ }