keystone_ui 0.115.0 → 0.116.0

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: 87aa10a28028755434c8b21070aa32d44e42291e02813d4653f522274f602136
4
- data.tar.gz: 6eec2aa0c1e83644f824e400217119b210c856c7cc21b315162b0ce2d3640b65
3
+ metadata.gz: a0e5e7067349b11ed6d7fe191d3a48888dfed6964bac6b57055bc2db6078ba12
4
+ data.tar.gz: d3e1556bbcc2489e643b2298083da64cffb29c82ac007166a7bc8cb42a7361c7
5
5
  SHA512:
6
- metadata.gz: 1c16dbbe2a5f6296417fef7130959e8337024a3eb14323fae45520593c9d6514c1679c1f6bc19af6ceec6859e0f5e51f861e69228fb0b6223e1f69a547febeb2
7
- data.tar.gz: e6e42cf9a08466361f5b61a580a9cf1c5021b497042b0671d3ba9710825091e44a142beaf6cba2f7ca3ddc6edfd90e954ad944a0a6272de5854cda906044f819
6
+ metadata.gz: 0a5e2896a81a9824375b69bcf97b9eb78534dc78452d30d11d776e71af4d2a34f5b574b09ac38be1287c395a9aef6f8a026fd827b0789c638c7902ab8b5f56e0
7
+ data.tar.gz: d6e5a49a919ed9a949edd9ddfabef488da73972e9513571ffc7ea0dbf42afb82253d389782c3bf6c775cb709fc2e2178f7ae9e39aabafca751420fb5eaac7beb
@@ -8,8 +8,12 @@ export default class extends Controller {
8
8
 
9
9
  async search() {
10
10
  if (this.takesNewNameValue) this.idTarget.value = ""
11
+ const search = this.startSearch()
11
12
  const response = await fetch(`${this.urlValue}?q=${encodeURIComponent(this.inputTarget.value)}`, { headers: { Accept: "application/json" } })
12
- this.matches = await response.json()
13
+ const matches = await response.json()
14
+ if (search !== this.latestSearch) return
15
+
16
+ this.matches = matches
13
17
  this.highlighted = -1
14
18
  this.draw()
15
19
  this.listTarget.classList.remove("hidden")
@@ -45,14 +49,21 @@ export default class extends Controller {
45
49
 
46
50
  choose(event) {
47
51
  event.preventDefault()
52
+ this.startSearch()
48
53
  this.idTarget.value = String(event.params.id)
49
54
  this.inputTarget.value = event.params.label
50
55
  if (this.hasNewFieldsTarget) this.newFieldsTarget.classList.add("hidden")
51
56
  this.listTarget.classList.add("hidden")
52
57
  }
53
58
 
59
+ startSearch() {
60
+ this.latestSearch = (this.latestSearch || 0) + 1
61
+ return this.latestSearch
62
+ }
63
+
54
64
  chooseNew(event) {
55
65
  event.preventDefault()
66
+ this.startSearch()
56
67
  this.idTarget.value = ""
57
68
  if (this.hasNewFieldsTarget) this.newFieldsTarget.classList.remove("hidden")
58
69
  this.listTarget.classList.add("hidden")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.115.0"
4
+ VERSION = "0.116.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystone_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.115.0
4
+ version: 0.116.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider