sdr_view_components 0.18.0 → 0.18.1

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: 5f59b6686400993be3c942c3f2b7c090fdb94c2e3f9aa7f5a6b83ba2818ec8dd
4
- data.tar.gz: 7dea52d93f22c5aaca0e81dbd98abf50e12185cdffbd8a720b4dfc20801e5774
3
+ metadata.gz: 5de046f013212327fcf03eefd5dcbdaa0918dc20a8a33687036d6802ec5f98fe
4
+ data.tar.gz: afe2f59fef8352750a73ee9327e5e39d253571dc7792aa887208b5b072465611
5
5
  SHA512:
6
- metadata.gz: 7b5e0f8baac5f81b0fac04d9e44473c37e940def8cabe7f37625d84c840c8888d7a9fc7441b74d2c710c7bc621917577d6df96b5030ededaa3133f0671578553
7
- data.tar.gz: 0d05f092127a49264b7418bb582722c15d246e3e2beb5dd1b95ecff4affc5ca19590aa800f5821a46884a27dac4112f59b2a48ce82f69fafb8dae5eaf2d48c16
6
+ metadata.gz: 6452476e378e3df685166323eac91b36a6df362e9b2db163b2fd4dbc4365b7211cab17ede65438b82ad9a9a8133a027372aee706cf2acc24af544a301f803c32
7
+ data.tar.gz: ad821a7e03619fb08e414ddcef5143e59399c11b4c3b6e2899334684cbbeba48a0b35ba62ea9b571c74e129435c57e20d37cba43ebe5cda2d543f3c0b3075c88
@@ -30,12 +30,27 @@ module SdrViewComponents
30
30
 
31
31
  def select(method, choices = nil, options = {}, html_options = {}, &)
32
32
  html_options[:form] ||= id
33
- super
33
+ return super unless html_options[:multiple] && options.fetch(:include_hidden, true)
34
+
35
+ # Rails' hidden blank input (so that selecting nothing is submitted) doesn't get the form attribute.
36
+ select_hidden_field(method, html_options) +
37
+ super(method, choices, options.merge(include_hidden: false), html_options, &)
34
38
  end
35
39
 
36
40
  def id
37
41
  super || options[:parent_builder]&.id
38
42
  end
43
+
44
+ private
45
+
46
+ def select_hidden_field(method, html_options)
47
+ hidden_options = { value: '', multiple: true, form: html_options[:form], name: html_options[:name],
48
+ disabled: html_options[:disabled] }.compact
49
+ # Without an id, so that it doesn't duplicate the select's.
50
+ hidden_options[:id] = nil
51
+ hidden_options[:autocomplete] = 'off' unless ActionView::Base.remove_hidden_field_autocomplete
52
+ hidden_field(method, hidden_options)
53
+ end
39
54
  end
40
55
  end
41
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrViewComponents
4
- VERSION = '0.18.0'
4
+ VERSION = '0.18.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdr_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Collier