ultimate_turbo_modal 2.1.1 → 2.1.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: '070742966b297c5aec10941f765cba344f5f4a5c4157dfa81f0fbafabcd3b329'
4
- data.tar.gz: 2ad6633a34d074276d774b6665ae581561a1b06b96dac8e59660dddc9ded2674
3
+ metadata.gz: 17d0eab498c9c828467bea1e33c1250763a8361595847a29a421bedc84947f06
4
+ data.tar.gz: 41ab99f7579857ccd65d7c549d8626d2566fb952cabb5c97b7f8193e7930fa44
5
5
  SHA512:
6
- metadata.gz: 23e754a2b8b76194129380d520303652025eb763577b592ff0daf95eb0e2800883fccf0772f6ff3159ac03941655b4860c3327ce37a16bdc0a77749d2d56bb2e
7
- data.tar.gz: 9d7f91f17a90ec51fb75c84d9ce11fc31a98b02b92bf4aaa7e3221c9496f8c390d198566af23d81996bc28229fb71890791e7aad55a42f3ab3fedeb25c3c184a
6
+ metadata.gz: e4925980e51ac9f8fc7e08245e8d79e3a73faca356e44ae45bedfd089e3ec3d2de17e2a5ab264f57dcae0c79b91a53e37ee3661dcb57541b422b563f3e2a8ff1
7
+ data.tar.gz: 93f0bb944adfcc54e844ce3d2d3438bdfdaabb3cd648bb22b87937a6b8267a46e842db622ffc7c04c7b9a2a578da3ea1c4c411742f44821368c4fd299a1c411f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [2.1.2] - 2025-08-06
2
+
3
+ - Fixed scroll lock
4
+
1
5
  ## [2.1.1] - 2025-08-05
2
6
 
3
7
  - Reduce Rails dependency to only required components (actionpack, activesupport, railties) (#22)
data/CLAUDE.md CHANGED
@@ -13,7 +13,7 @@ Ultimate Turbo Modal (UTMR) is a full-featured modal implementation for Rails ap
13
13
  - `configuration.rb`: Global configuration management
14
14
  - `helpers/`: Rails helpers for views and controllers
15
15
  - Generators in `/lib/generators/` for installation
16
-
16
+
17
17
  - **JavaScript Package**: Located in `/javascript/`
18
18
  - `modal_controller.js`: Stimulus controller for modal behavior
19
19
  - `index.js`: Main entry point
@@ -79,4 +79,4 @@ When adding a new option:
79
79
  ## Testing Approach
80
80
  - JavaScript: No test framework currently set up
81
81
  - Ruby: Use standard Rails testing practices
82
- - Manual testing via the demo app: https://github.com/cmer/ultimate_turbo_modal-demo
82
+ - Manual testing via the demo app (located in `./demo-app`)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ultimate_turbo_modal (2.1.1)
4
+ ultimate_turbo_modal (2.1.2)
5
5
  actionpack
6
6
  activesupport
7
7
  phlex-rails
data/README.md CHANGED
@@ -122,9 +122,40 @@ Do not get overwhelmed with all the options. The defaults are sensible.
122
122
  - Focus trap for improved accessibility (Tab and Shift+Tab cycle through focusable elements within the modal only)
123
123
 
124
124
 
125
- ## Demo
125
+ ## Demo Video
126
126
 
127
- A demo application can be found at https://github.com/cmer/ultimate_turbo_modal-demo. A video demo can be seen here: [https://youtu.be/BVRDXLN1I78](https://youtu.be/BVRDXLN1I78).
127
+ A video demo can be seen here: [https://youtu.be/BVRDXLN1I78](https://youtu.be/BVRDXLN1I78).
128
+
129
+ ### Running the Demo Application
130
+
131
+ The repository includes a demo application in the `demo-app` directory that showcases all the features of Ultimate Turbo Modal. To run it locally:
132
+
133
+ ```bash
134
+ # Navigate to the demo app directory
135
+ cd demo-app
136
+
137
+ # Install Ruby dependencies
138
+ bundle install
139
+
140
+ # Create and setup the database
141
+ bin/rails db:create db:migrate db:seed
142
+
143
+ # Install JavaScript dependencies
144
+ yarn install
145
+
146
+ # Start the development server
147
+ bin/dev
148
+
149
+ # Open your browser
150
+ open http://localhost:3000
151
+ ```
152
+
153
+ The demo app provides examples of:
154
+ - Basic modal usage
155
+ - Different modal configurations
156
+ - Custom styling options
157
+ - Various trigger methods
158
+ - Advanced features like scrollable content and custom footers
128
159
 
129
160
  ## Upgrading from 1.x
130
161
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.1.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- ultimate_turbo_modal (2.0.4)
4
+ ultimate_turbo_modal (2.1.1)
5
5
  actionpack
6
6
  activesupport
7
7
  phlex-rails
@@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base
3
3
 
4
4
  def set_modal_properties
5
5
  %i[padding advance close_button].each do |it|
6
- instance_variable_set("@#{it}", params[it] == "1")
6
+ instance_variable_set("@#{it}", params[it] == "1" || params[it].nil?)
7
7
  end
8
8
  @override_url = "/custom-advance-history-url" if @advance
9
9
  end
data/demo-app/bin/dev CHANGED
@@ -1,7 +1,18 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
+ # Build the ultimate_turbo_modal JavaScript package
4
+ echo "Building ultimate_turbo_modal JavaScript package..."
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ DEMO_APP_DIR="$SCRIPT_DIR/.."
7
+ (cd "$DEMO_APP_DIR/../javascript" && yarn build)
8
+
9
+ # Reinstall to pick up the latest changes
10
+ echo "Installing latest ultimate_turbo_modal in demo app..."
11
+ yarn install --force
12
+
13
+ # Start the development servers
3
14
  if command -v overmind &> /dev/null; then
4
- overmind start -f Procfile.dev "$@"
15
+ overmind start -f $DEMO_APP_DIR/Procfile.dev "$@"
5
16
  else
6
- foreman start -f Procfile.dev "$@"
17
+ foreman start -f $DEMO_APP_DIR/Procfile.dev "$@"
7
18
  fi
data/demo-app/yarn.lock CHANGED
@@ -479,6 +479,13 @@ flatpickr@^4.6.13:
479
479
  resolved "https://registry.yarnpkg.com/flatpickr/-/flatpickr-4.6.13.tgz#8a029548187fd6e0d670908471e43abe9ad18d94"
480
480
  integrity sha512-97PMG/aywoYpB4IvbvUJi0RQi8vearvU0oov1WW3k0WZPBMrTQVqekSX5CjSG/M4Q3i6A/0FKXC7RyAoAUUSPw==
481
481
 
482
+ focus-trap@^7.6.5:
483
+ version "7.6.5"
484
+ resolved "https://registry.yarnpkg.com/focus-trap/-/focus-trap-7.6.5.tgz#56f0814286d43c1a2688e9bc4f31f17ae047fb76"
485
+ integrity sha512-7Ke1jyybbbPZyZXFxEftUtxFGLMpE2n6A+z//m4CRDlj0hW+o3iYSmh8nFlYMurOiJVDmJRilUQtJr08KfIxlg==
486
+ dependencies:
487
+ tabbable "^6.2.0"
488
+
482
489
  fraction.js@^4.3.6:
483
490
  version "4.3.7"
484
491
  resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.7.tgz#06ca0085157e42fda7f9e726e79fefc4068840f7"
@@ -936,6 +943,11 @@ supports-preserve-symlinks-flag@^1.0.0:
936
943
  resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
937
944
  integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
938
945
 
946
+ tabbable@^6.2.0:
947
+ version "6.2.0"
948
+ resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-6.2.0.tgz#732fb62bc0175cfcec257330be187dcfba1f3b97"
949
+ integrity sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==
950
+
939
951
  tailwindcss@4.1.3, tailwindcss@^4.1.3:
940
952
  version "4.1.3"
941
953
  resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-4.1.3.tgz#f5a6b4451295c06e213013697f7193be1630fa46"
@@ -959,11 +971,12 @@ to-regex-range@^5.0.1:
959
971
  is-number "^7.0.0"
960
972
 
961
973
  "ultimate_turbo_modal@file:../javascript":
962
- version "2.0.4"
974
+ version "2.1.1"
963
975
  dependencies:
964
976
  "@hotwired/stimulus" "^3.2.2"
965
977
  "@hotwired/turbo-rails" "^8.0.0"
966
978
  el-transition "^0.0.7"
979
+ focus-trap "^7.6.5"
967
980
  idiomorph "^0.7.3"
968
981
 
969
982
  universalify@^2.0.0:
@@ -20,6 +20,10 @@ export default class extends Controller {
20
20
  // Initialize focus trap instance variable
21
21
  this.focusTrapInstance = null;
22
22
 
23
+ // Store original body styles for scroll lock
24
+ this.originalBodyOverflow = null;
25
+ this.scrollPosition = 0;
26
+
23
27
  this.showModal();
24
28
 
25
29
  this.turboFrame = this.element.closest('turbo-frame');
@@ -41,6 +45,9 @@ export default class extends Controller {
41
45
  }
42
46
 
43
47
  showModal() {
48
+ // Lock body scroll
49
+ this.#lockBodyScroll();
50
+
44
51
  enter(this.containerTarget).then(() => {
45
52
  // Activate focus trap after the modal transition is complete
46
53
  this.#activateFocusTrap();
@@ -112,6 +119,9 @@ export default class extends Controller {
112
119
  }
113
120
 
114
121
  #resetModalElement() {
122
+ // Unlock body scroll
123
+ this.#unlockBodyScroll();
124
+
115
125
  leave(this.containerTarget).then(() => {
116
126
  this.turboFrame.removeAttribute("src");
117
127
  this.containerTarget.remove();
@@ -187,4 +197,35 @@ export default class extends Controller {
187
197
  this.focusTrapInstance = null;
188
198
  }
189
199
  }
200
+
201
+ #lockBodyScroll() {
202
+ // Store the current scroll position
203
+ this.scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
204
+
205
+ // Store the original overflow style
206
+ this.originalBodyOverflow = document.body.style.overflow;
207
+
208
+ // Prevent scrolling on the body
209
+ document.body.style.overflow = 'hidden';
210
+ document.body.style.position = 'fixed';
211
+ document.body.style.top = `-${this.scrollPosition}px`;
212
+ document.body.style.width = '100%';
213
+ }
214
+
215
+ #unlockBodyScroll() {
216
+ // Restore the original overflow style
217
+ if (this.originalBodyOverflow !== null) {
218
+ document.body.style.overflow = this.originalBodyOverflow;
219
+ } else {
220
+ document.body.style.removeProperty('overflow');
221
+ }
222
+
223
+ // Remove position styles
224
+ document.body.style.removeProperty('position');
225
+ document.body.style.removeProperty('top');
226
+ document.body.style.removeProperty('width');
227
+
228
+ // Restore the scroll position
229
+ window.scrollTo(0, this.scrollPosition);
230
+ }
190
231
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate_turbo_modal",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "The ultimate Turbo / Stimulus / Hotwire modal window for Rails",
5
5
  "main": "dist/ultimate_turbo_modal.min.js",
6
6
  "module": "dist/ultimate_turbo_modal.min.js",
@@ -123,7 +123,7 @@ class UltimateTurboModal::Base < Phlex::HTML
123
123
 
124
124
  def styles
125
125
  style do
126
- str = "html:has(dialog[open]) {overflow: hidden;} html {scrollbar-gutter: stable;}".html_safe
126
+ str = "html:has(dialog[open]),html:has(#modal-container) {overflow: hidden;} html {scrollbar-gutter: stable;}".html_safe
127
127
  respond_to?(:unsafe_raw) ? unsafe_raw(str) : raw(str)
128
128
  end
129
129
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultimate_turbo_modal
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Mercier