formatic 1.0.2 → 1.0.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: b1f958296d240381290011236ccff9c70dafe0d2b965cc0199f76ded99ae09c1
4
- data.tar.gz: 70e142426fc515e4d4f375824da349e1f0c8917809b6a5cfbbbb9c5923d502bf
3
+ metadata.gz: 37f8b7cde266344ad8597634fbe702030dbcf9021e16a2e4273fc90a886a2697
4
+ data.tar.gz: 53de1295f3b0cb2687e3f07e8ce37cd897b13b2f6923678489955ee51a4a3d08
5
5
  SHA512:
6
- metadata.gz: 15b70366584a928835d9e29ed854f1037e5f0a703dcebb0298b5d558bb74a214c4fffae7f432db8ff5fc1f00293b445a6097de236428f73e5eead6f1feebf923
7
- data.tar.gz: fa7ed00c5bf20432715f24c4f77fcc8bc8fdb5c109f1b6a27e1daaecd967209f88cce16ff716adb4da615494c317eb525d2fdabe047cd1d65fc41848507327f2
6
+ metadata.gz: 645d9a56e0010f77000db7af8ccd0a99678db1b63ca6518ea197a964d86ad6740dbd4b5f0614a6f19e681ec396550d224af8a9f1c3ca512cf65f95ce28260871
7
+ data.tar.gz: 5c46a952c0816db10e8f6d8896d1a3e396de456192258e83027eef87aec327b86129bb6c672b4533cdf71d93a8e2281def708dd10a16e08163963cbe4bf383d2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.0.3] - 2026-11-11
2
+
3
+ - Rack test `search` helper chooses the matching quick-pick radio directly when the query matches, falling back to the endpoint search otherwise
4
+
1
5
  ## [1.0.2] - 2026-11-11
2
6
 
3
7
  - Search quick-pick and tab IDs carry a per-instance token, so multiple `Formatic::Search` inputs on one page no longer hijack each other's clicks
@@ -19,6 +19,11 @@ module Formatic
19
19
  ensure_rack_test_driver!
20
20
  query_field = find_query_field(page, from)
21
21
  component = search_component(query_field)
22
+
23
+ if (record = matching_pick(component, query))
24
+ return record
25
+ end
26
+
22
27
  record = matching_record(search_records(component), query)
23
28
 
24
29
  raise SelectionError, "No result matching #{query.inspect} from #{from.inspect}" unless record
@@ -87,6 +92,20 @@ module Formatic
87
92
  end
88
93
  end
89
94
 
95
+ # The autocomplete search needs JavaScript, which Rack cannot execute.
96
+ # The component already renders favorites as quickpick radios in the HTML.
97
+ # When the wanted record is among the quickpicks, choose the matching radio directly.
98
+ # Otherwise the caller falls back to the endpoint search.
99
+ def matching_pick(component, query)
100
+ pick = component.all('label.js-formatic-search__pick-label', visible: :all)
101
+ .find { |label| label.text.downcase.include?(query.downcase) }
102
+ return if pick.nil?
103
+
104
+ radio = pick.find('input[type=radio]', visible: :all)
105
+ page.choose(radio[:id], visible: :all)
106
+ { 'id' => radio.value }
107
+ end
108
+
90
109
  def apply_selection(component, query_field, record)
91
110
  component.find('.js-formatic-search__value', visible: :all).set(record.fetch('id').to_s)
92
111
  selected = component.find('.js-formatic-search__selected', visible: :all)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Formatic
4
- VERSION = '1.0.2'
4
+ VERSION = '1.0.3'
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.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - halo