ideasbugs 0.5.2 → 0.5.4

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: fbdc5c2d176499e4bc54ef89013a7e60c56c694787021cb6eb8ead38f8cb28ea
4
- data.tar.gz: f4d6ef3316a06cd0615b8b0b11e18a2712dac7c40dedb661542d9be481618b14
3
+ metadata.gz: 8959223a89b198251b3fe0697330ebe2fe2054bfa8c0a258bb3ef9470d3f171b
4
+ data.tar.gz: fb7b3d95aac04d6e70942377b714771cd33ac10732d29833405446425c1ab8f2
5
5
  SHA512:
6
- metadata.gz: 7a5ce4d1fcd811b2883ec8aca1b80a9f20579690a4320af3e6ef24bde6228bf0c370d3bf116b075c27e2c35b61ced943b7c6e36df08983f0847fc657b4f6c59b
7
- data.tar.gz: 8bec9adf1132529e22053c589bc2d548e5d0676eddddd381674305f27f56962edb2a00171cc41c1b9145d2cac3ae5919e8c6f2d78529933b9f8c663a4095f4ac
6
+ metadata.gz: 304eb89d1bd1529e54356e8eaa647f004c85f7cc5eddf040fa746cc3c5a5a654a26da06235fd57d1010da3c477fbf7d45fb143d99775c73f38af02971c372b85
7
+ data.tar.gz: e54f393078ca2e69afc9ecba2b81bb44849ce91c69501c14e84af4c820daa586bf421079f75c66b601086eee99be505832950804631d0f1624a0edaa4e58ac1a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.4 (2026-07-25)
4
+
5
+ - Docs: show how to wire current_user with Rails 8's built-in authentication
6
+ (bin/rails generate authentication), alongside the existing Devise/Warden
7
+ example — in the README and the generated initializer.
8
+
9
+ ## 0.5.3 (2026-07-25)
10
+
11
+ - The widget's dynamic messages are now announced to screen readers: the
12
+ validation/save error paragraph is a `role="alert"` region created before
13
+ any text lands in it, and the post-submit thanks note is an
14
+ `aria-live="polite"` status region inserted empty and then filled, so the
15
+ announcement actually fires.
16
+ - The page behind the open widget dialog no longer scrolls: opening the
17
+ dialog locks `<html>` overflow and closing it restores the previous value.
18
+ Because the lock lives on `<html>` (which survives Turbo body swaps), the
19
+ per-visit render step also releases a stale lock whenever the overlay is
20
+ no longer in the DOM.
21
+
3
22
  ## 0.5.2 (2026-07-25)
4
23
 
5
24
  - **Fixed: the widget went dead after Turbo Drive navigations under a
data/README.md CHANGED
@@ -163,6 +163,20 @@ Ideasbugs.configure do |config|
163
163
  end
164
164
  ```
165
165
 
166
+ `current_user` (and any admin gate) receives the raw request, so it works
167
+ with whatever auth you have:
168
+
169
+ ```ruby
170
+ # Devise / Warden:
171
+ config.current_user = ->(request) { request.env["warden"]&.user }
172
+
173
+ # Rails 8 built-in auth (bin/rails generate authentication):
174
+ config.current_user = lambda do |request|
175
+ token = request.cookies["session_token"]
176
+ Session.find_signed(token)&.user if token
177
+ end
178
+ ```
179
+
166
180
  ### Opening the form from your own UI
167
181
 
168
182
  Prefer a nav item over the floating button? Add `data-ideasbugs-open` to
@@ -11,7 +11,14 @@ Ideasbugs.configure do |config|
11
11
 
12
12
  # Attribute feedback to a user (optional). Return an object responding to
13
13
  # #id, or nil. Receives the request.
14
+ # Devise / Warden:
14
15
  # config.current_user = ->(request) { request.env["warden"]&.user }
16
+ #
17
+ # Rails 8 built-in auth (bin/rails generate authentication):
18
+ # config.current_user = lambda do |request|
19
+ # token = request.cookies["session_token"]
20
+ # Session.find_signed(token)&.user if token
21
+ # end
15
22
 
16
23
  # Label stored for the author and shown in the dashboard.
17
24
  # config.author_label = ->(user) { user.try(:email) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ideasbugs
4
- VERSION = '0.5.2'
4
+ VERSION = '0.5.4'
5
5
  end
@@ -20,6 +20,20 @@
20
20
  var Z = 2147483000;
21
21
  var overlay = null;
22
22
  var lastFocused = null;
23
+ var savedOverflow = null;
24
+
25
+ // The lock lives on <html>, which survives Turbo body swaps — so a swap can
26
+ // drop the overlay without closeForm() running; render() releases it then.
27
+ function lockScroll() {
28
+ savedOverflow = document.documentElement.style.overflow;
29
+ document.documentElement.style.overflow = "hidden";
30
+ }
31
+
32
+ function unlockScroll() {
33
+ if (savedOverflow === null) return;
34
+ document.documentElement.style.overflow = savedOverflow;
35
+ savedOverflow = null;
36
+ }
23
37
 
24
38
  function ready(fn) {
25
39
  if (document.readyState === "loading") {
@@ -55,6 +69,10 @@
55
69
  // Re-read on each visit: the config block is data (not an executed
56
70
  // script), so it reflects the page Turbo just rendered.
57
71
  config = readConfig() || config;
72
+ if (overlay && !document.body.contains(overlay)) {
73
+ overlay = null;
74
+ unlockScroll();
75
+ }
58
76
  injectStyles();
59
77
  if (config.showButton !== false) buildButton();
60
78
  }
@@ -108,6 +126,7 @@
108
126
  dialog.appendChild(form());
109
127
  overlay.appendChild(dialog);
110
128
  document.body.appendChild(overlay);
129
+ lockScroll();
111
130
 
112
131
  // Keep Tab (and Shift+Tab) cycling inside the dialog while it is open.
113
132
  overlay.addEventListener("keydown", trapFocus);
@@ -120,6 +139,7 @@
120
139
  if (!overlay) return;
121
140
  overlay.remove();
122
141
  overlay = null;
142
+ unlockScroll();
123
143
  if (lastFocused && lastFocused.focus) lastFocused.focus();
124
144
  }
125
145
 
@@ -172,6 +192,9 @@
172
192
 
173
193
  var error = document.createElement("p");
174
194
  error.className = "idb-error";
195
+ // The alert region exists (empty) before any text lands in it, so
196
+ // screen readers announce the message showError() later drops in.
197
+ error.setAttribute("role", "alert");
175
198
  error.hidden = true;
176
199
  form.appendChild(error);
177
200
 
@@ -331,8 +354,14 @@
331
354
  dialog.textContent = "";
332
355
  var note = document.createElement("p");
333
356
  note.className = "idb-thanks";
334
- note.textContent = config.labels.thanks;
357
+ // Success is a status, not an alert. Insert the region empty and fill it
358
+ // afterwards: screen readers announce text landing in an existing polite
359
+ // region, but may skip a node that arrives already carrying its text.
360
+ note.setAttribute("aria-live", "polite");
335
361
  dialog.appendChild(note);
362
+ setTimeout(function () {
363
+ note.textContent = config.labels.thanks;
364
+ }, 0);
336
365
  setTimeout(closeForm, 1600);
337
366
  }
338
367
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ideasbugs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov