uber_select_rails 1.0.1 → 1.0.2

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: d51d24fdd5654b3bb38de1b77cf390a1f358154825fe7c99a542eff6826b2c2a
4
- data.tar.gz: c643f0571b53b9872ddb77cf323012c2627527d8eb82a132a7f970936bb596ef
3
+ metadata.gz: 319a0fff993d0b4459b4942a5a1081ec6a7ac0283a02a4f993a512ebe078c96c
4
+ data.tar.gz: 9c655d2f4378e657f0a392e40c8d67c59ac183fd6624c760f69fca23039637b1
5
5
  SHA512:
6
- metadata.gz: 6b85d2aa32eed2569c9fc206fdf779ba65ab7eeeddabb8abfacc4ff67fce5c847de80429b346a8747d34dd7f0affd43de8d75e142401693fd7bfea672d829462
7
- data.tar.gz: e835ce7e9b51b1cc668b1fed8e3ecfbdc5f59cd240160525296236703fa9376b61a6b7efb820a2b55df92244a8605b0d5805a881e8bb186ef7ba84aa15ca4af3
6
+ metadata.gz: f98ff711d2dd822ca3c7f96312297bfb7a06197a92c66887c47b7760cf4c3d1319324af88a95ff096aa2f3dd33e39d37280a1f84a9276eebfd02df1ef5fd7775
7
+ data.tar.gz: c14751aceaa501a9e0387ac8c2ab043ce384cdd9b44eee5903145a931d9fc7fc6950d2b74d0f70a35bf5b49f225a656729c6713bffe3aff319135134459d0fe6
@@ -1,3 +1,3 @@
1
1
  module UberSelectRails
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -124,6 +124,8 @@
124
124
  return results().filter('.highlighted')
125
125
  }
126
126
 
127
+ this.highlightedResult = highlightedResult
128
+
127
129
  function selectableResults(){
128
130
  return visibleResults().not('.disabled')
129
131
  }
@@ -57,6 +57,15 @@
57
57
  $(context).trigger('inputDownArrow')
58
58
  })
59
59
 
60
+ // Handle ENTER key in search input
61
+ $(queryInput).on('querySubmit', function() {
62
+ var highlightedResult = list.highlightedResult()
63
+
64
+ if (highlightedResult.length) {
65
+ highlightedResult.click()
66
+ }
67
+ })
68
+
60
69
  $(model).on('resultsUpdated', function(){
61
70
  context.renderResults()
62
71
  })
@@ -43,10 +43,10 @@
43
43
  triggerEvent('clear')
44
44
  })
45
45
 
46
- // When the enter button is pressed
47
46
  input.on('keydown', function(event){
48
- if (event.which == 13){
47
+ if (event.which == 13){ // When the enter button is pressed
49
48
  triggerEvent('querySubmit')
49
+ return false;
50
50
  }
51
51
 
52
52
  if (event.which == 38) { // Up Arrow
@@ -89,8 +89,11 @@
89
89
  } else if (index < 0) {
90
90
  setOutputContainerAria("aria-activedescendant", "")
91
91
  $(outputContainer.view).focus()
92
- } else {
92
+ } else if (result) {
93
+ // Check if result exists (e.g., when pressing down on the last item, result will be undefined)
93
94
  setOutputContainerAria("aria-activedescendant", result.id)
95
+ } else {
96
+ setOutputContainerAria("aria-activedescendant", "")
94
97
  }
95
98
  })
96
99
 
@@ -259,6 +259,20 @@
259
259
  <p>This example has an option with a <code>title</code> attribute that should show as a tooltip.</p>
260
260
  </span>
261
261
 
262
+ <span class="example">
263
+ <label for="select">
264
+ Form ENTER handling (should not submit form)
265
+ </label>
266
+ <form onsubmit="alert('Form submitted! This should NOT happen when pressing ENTER in the search field.'); return false;">
267
+ <select placeholder="Choose a gender">
268
+ <option></option>
269
+ <option>male</option>
270
+ <option>female</option>
271
+ </select>
272
+ <button type="submit">Submit Form</button>
273
+ </form>
274
+ </span>
275
+
262
276
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
263
277
  <script src="javascript/uber_search.js"></script>
264
278
  <script src="javascript/uber_search/search_field.js"></script>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uber_select_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen