formatic 1.0.3 → 1.0.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: 37f8b7cde266344ad8597634fbe702030dbcf9021e16a2e4273fc90a886a2697
4
- data.tar.gz: 53de1295f3b0cb2687e3f07e8ce37cd897b13b2f6923678489955ee51a4a3d08
3
+ metadata.gz: 7af22aa2b9a0b0f1c08544a87127b14dfc941adc37394091ddf8af2e776b66ec
4
+ data.tar.gz: 6e06db902597c3ba6ad82977a02f8991d90cc2412250f70d7fb7d07e1fe590f0
5
5
  SHA512:
6
- metadata.gz: 645d9a56e0010f77000db7af8ccd0a99678db1b63ca6518ea197a964d86ad6740dbd4b5f0614a6f19e681ec396550d224af8a9f1c3ca512cf65f95ce28260871
7
- data.tar.gz: 5c46a952c0816db10e8f6d8896d1a3e396de456192258e83027eef87aec327b86129bb6c672b4533cdf71d93a8e2281def708dd10a16e08163963cbe4bf383d2
6
+ metadata.gz: f4a0615255123699957ce1b08a0e65349ad276c1d5ebd1aaf10b641ee9fc996b57b147acf4730e985b8d9e4f51d308e77c54dcfc2bf06352cce6d03a76f2e5be
7
+ data.tar.gz: b7473fd62e049f5e5e22a656bdade50c135c41f84eebba1d63c689f29064f3ce7108cfd4e61b4c6d3745850122f344c1aac2f9a1e1bff14d958d66ee990a6434
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.0.4] - 2026-11-12
2
+
3
+ - Rack test `search` helper clears the `Formatic::Search` field on a blank query (`search '', from: 'Customer'`)
4
+
1
5
  ## [1.0.3] - 2026-11-11
2
6
 
3
7
  - Rack test `search` helper chooses the matching quick-pick radio directly when the query matches, falling back to the endpoint search otherwise
@@ -6,6 +6,7 @@ require 'calls'
6
6
  module Formatic
7
7
  module Testing
8
8
  # Selects a Formatic search result in a Rack test.
9
+ # A blank query clears the selection instead.
9
10
  class Search
10
11
  include Calls
11
12
 
@@ -20,16 +21,9 @@ module Formatic
20
21
  query_field = find_query_field(page, from)
21
22
  component = search_component(query_field)
22
23
 
23
- if (record = matching_pick(component, query))
24
- return record
25
- end
26
-
27
- record = matching_record(search_records(component), query)
28
-
29
- raise SelectionError, "No result matching #{query.inspect} from #{from.inspect}" unless record
24
+ return clear_selection(component, query_field) if query.nil? || query == ''
30
25
 
31
- apply_selection(component, query_field, record)
32
- record
26
+ select_record(component, query_field)
33
27
  end
34
28
 
35
29
  private
@@ -57,6 +51,19 @@ module Formatic
57
51
  query_field.find(:xpath, 'ancestor::div[contains(@class, "js-formatic-search")][1]')
58
52
  end
59
53
 
54
+ def select_record(component, query_field)
55
+ if (record = matching_pick(component, query))
56
+ return record
57
+ end
58
+
59
+ record = matching_record(search_records(component), query)
60
+
61
+ raise SelectionError, "No result matching #{query.inspect} from #{from.inspect}" unless record
62
+
63
+ apply_selection(component, query_field, record)
64
+ record
65
+ end
66
+
60
67
  def search_records(component)
61
68
  response = search_request(configured_value(component, 'url'), search_params(component))
62
69
 
@@ -113,6 +120,25 @@ module Formatic
113
120
  component.find('.js-formatic-search__results', visible: :all).native.inner_html = ''
114
121
  query_field.set('')
115
122
  end
123
+
124
+ # A blank query removes the current selection.
125
+ # The hidden value is blanked and re-enabled for submission.
126
+ # Checked quickpick radios are unchecked.
127
+ # The selected card and the results are emptied.
128
+ # The query input is blanked last.
129
+ def clear_selection(component, query_field)
130
+ value_input = component.find('.js-formatic-search__value', visible: :all)
131
+ value_input.native.remove_attribute('disabled')
132
+ value_input.set('')
133
+
134
+ component.all('input.js-formatic-search__pick', visible: :all).each do |radio|
135
+ radio.native.remove_attribute('checked')
136
+ end
137
+
138
+ component.find('.js-formatic-search__selected', visible: :all).native.inner_html = ''
139
+ component.find('.js-formatic-search__results', visible: :all).native.inner_html = ''
140
+ query_field.set('')
141
+ end
116
142
  end
117
143
  end
118
144
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Formatic
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - halo