lsa_tdx_feedback 2.0.1 → 2.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69d0dae8aaebab74ea26a463495be295ec35369e9ec579cdfe7ee008837fcbb3
4
- data.tar.gz: de81da8ce4c00ed435be260b49d7cd0bd447d963dae02c1d8094ece55fa9bd2d
3
+ metadata.gz: '096e6559693c5d6f846eeecd9e698bef3f32049cb5b49470cd12937701f9e16b'
4
+ data.tar.gz: 26b7d30ff119d3130c4e12aa5b1e6e0349b7e6541a19e575b894f008ebae1d09
5
5
  SHA512:
6
- metadata.gz: 5b2dd1661fc85b467a0c656ac2a6024a2735fbb81c8c2c7df90c33579e43d8b1da3595417ea52b1c86b8ac7bf96adcfc8762db8fe7b6b41cc3894b5b3dff0210
7
- data.tar.gz: d6bdfeb8dc93fc60fc41c03895303bef1a906a839508154e41d9bd910911bbe386b2f958c611adb00a91bb4d787a390df9fcaafc4fea5963eb0fce7aa645299a
6
+ metadata.gz: 845d9ff8859ea8ac5904a0aecdc31510baa656b427c3d7ca2626c107c853e2220d37cedf2ab700ac12a1908105ebfda9eb1bb3ffbd2b4dd8b60e7c895fd0f2f7
7
+ data.tar.gz: 2bf159c26ef8e6f0bf090fcb068fb066c568f9d336a08e551b49287c8b7bd8b8c03fad55d3f9cae75700b5c3b2e684e07bb9dee750f77a29211ad3004787d56f
data/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.2] - 2026-07-28
11
+
12
+ ### Fixed
13
+ - **Duplicate TDX tickets under Turbo Drive**: the feedback JS lives in the
14
+ layout `<body>`, and Turbo Drive re-evaluates body `<script>` tags on every
15
+ visit. Each re-evaluation created a new `LsaTdxFeedback` object and stacked
16
+ another `turbo:load` listener, so one form submit fired multiple `fetch`
17
+ POSTs and created multiple tickets. The script now reuses
18
+ `window.LsaTdxFeedback` when already present (re-`init` only) and registers
19
+ document-level listeners once.
20
+
10
21
  ## [2.0.1] - 2026-07-21
11
22
 
12
23
  ### Fixed
data/INSTALLATION.md CHANGED
@@ -106,21 +106,24 @@ Add the feedback modal to your application layout:
106
106
  <head>
107
107
  <!-- Your existing head content -->
108
108
  <%= lsa_tdx_feedback_css %>
109
+ <%= lsa_tdx_feedback_js %>
109
110
  </head>
110
111
 
111
112
  <body>
112
113
  <!-- Your existing body content -->
113
114
 
114
- <!-- Add the feedback modal -->
115
+ <!-- Add the feedback modal (must stay in the body) -->
115
116
  <%= lsa_tdx_feedback_modal %>
116
-
117
- <!-- Add the JavaScript before closing body tag -->
118
- <%= lsa_tdx_feedback_js %>
119
117
  </body>
120
118
  </html>
121
119
  ```
122
120
 
123
- Or use the all-in-one helper:
121
+ **Turbo Drive tip:** prefer loading the JS from `<head>` (as above). Body
122
+ scripts are re-evaluated on every Turbo visit; 2.0.2 guards against that, but
123
+ head placement still avoids redundant `init` work. Putting
124
+ `<%= lsa_tdx_feedback_js %>` before `</body>` remains supported.
125
+
126
+ Or use the all-in-one helper (assets + modal; modal still belongs in the body):
124
127
 
125
128
  ```erb
126
129
  <!-- app/views/layouts/application.html.erb -->
@@ -1,10 +1,22 @@
1
1
  /**
2
2
  * LsaTdxFeedback JavaScript - Self-contained feedback modal functionality
3
3
  * Turbo Drive compatible
4
+ *
5
+ * Turbo Drive re-evaluates <script> tags in the <body> on every visit. Guard
6
+ * against that so we keep a single singleton and a single set of document-level
7
+ * listeners; otherwise each navigation stacks another turbo:load handler and
8
+ * form submits create duplicate TDX tickets.
4
9
  */
5
10
  (function() {
6
11
  'use strict';
7
12
 
13
+ // Script re-executed after a Turbo body swap: reuse the existing instance and
14
+ // re-bind to the new modal/form DOM. Do not register more document listeners.
15
+ if (window.LsaTdxFeedback && typeof window.LsaTdxFeedback.init === 'function') {
16
+ window.LsaTdxFeedback.init();
17
+ return;
18
+ }
19
+
8
20
  var LsaTdxFeedback = {
9
21
  initialized: false,
10
22
  modal: null,
@@ -1,3 +1,3 @@
1
1
  module LsaTdxFeedback
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lsa_tdx_feedback
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - LSA Rails Team