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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/formatic/testing/search.rb +19 -0
- data/lib/formatic/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37f8b7cde266344ad8597634fbe702030dbcf9021e16a2e4273fc90a886a2697
|
|
4
|
+
data.tar.gz: 53de1295f3b0cb2687e3f07e8ce37cd897b13b2f6923678489955ee51a4a3d08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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)
|
data/lib/formatic/version.rb
CHANGED