ideasbugs 0.5.2 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbdc5c2d176499e4bc54ef89013a7e60c56c694787021cb6eb8ead38f8cb28ea
4
- data.tar.gz: f4d6ef3316a06cd0615b8b0b11e18a2712dac7c40dedb661542d9be481618b14
3
+ metadata.gz: 29449ba188f3e7da8299dd22ff9f03795cd5b645734596619eb5318535c8a809
4
+ data.tar.gz: 6d5853b6e7db868f7caa5203575d09fef1d1fde2a9823ee32e09e6dbf82f9f05
5
5
  SHA512:
6
- metadata.gz: 7a5ce4d1fcd811b2883ec8aca1b80a9f20579690a4320af3e6ef24bde6228bf0c370d3bf116b075c27e2c35b61ced943b7c6e36df08983f0847fc657b4f6c59b
7
- data.tar.gz: 8bec9adf1132529e22053c589bc2d548e5d0676eddddd381674305f27f56962edb2a00171cc41c1b9145d2cac3ae5919e8c6f2d78529933b9f8c663a4095f4ac
6
+ metadata.gz: 7fbd87765283a0c53e058c50d8a94318b0ddd79b4abb43c14fcf4782b1041c6b984bb4740e927f5d4fb8a9451718a3676afa42dfb4d1ffb686cb20afb981cee2
7
+ data.tar.gz: 60fc9116964d2035b5640201eedbfa4ffefd766c517f89fb0a1aab03e2178365bfc53856f220706631638be6f6b09e9e345fc881a82daf869c8774c694ca1a59
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.3 (2026-07-25)
4
+
5
+ - The widget's dynamic messages are now announced to screen readers: the
6
+ validation/save error paragraph is a `role="alert"` region created before
7
+ any text lands in it, and the post-submit thanks note is an
8
+ `aria-live="polite"` status region inserted empty and then filled, so the
9
+ announcement actually fires.
10
+ - The page behind the open widget dialog no longer scrolls: opening the
11
+ dialog locks `<html>` overflow and closing it restores the previous value.
12
+ Because the lock lives on `<html>` (which survives Turbo body swaps), the
13
+ per-visit render step also releases a stale lock whenever the overlay is
14
+ no longer in the DOM.
15
+
3
16
  ## 0.5.2 (2026-07-25)
4
17
 
5
18
  - **Fixed: the widget went dead after Turbo Drive navigations under a
@@ -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.3'
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov