uber_select_rails 1.0.0 → 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: 4e848d17e956bbe5c52f9f7e299e47cc2cb296755ae8ce7cbf94877b5a4857ca
4
- data.tar.gz: 87fdd8c564c2960b8d20015245aeb48b28b8c2ee7b7e12e42fd393eb49ebaeec
3
+ metadata.gz: 319a0fff993d0b4459b4942a5a1081ec6a7ac0283a02a4f993a512ebe078c96c
4
+ data.tar.gz: 9c655d2f4378e657f0a392e40c8d67c59ac183fd6624c760f69fca23039637b1
5
5
  SHA512:
6
- metadata.gz: 4500a0a600213b393da36f7676deee006ddd301f4f258d336017e2d0260182615da1a75ccda716f231049e357049a23a25b1b26a88597d844f39423babb202b7
7
- data.tar.gz: 38d0c07a95368fcdaaa6d3338f21e572a846cf70142353e2a1ec365e6f4a9222c3ac060cd1cca6a4321b4aa1866b62421c3b1ab887e148a89801497975cda09b
6
+ metadata.gz: f98ff711d2dd822ca3c7f96312297bfb7a06197a92c66887c47b7760cf4c3d1319324af88a95ff096aa2f3dd33e39d37280a1f84a9276eebfd02df1ef5fd7775
7
+ data.tar.gz: c14751aceaa501a9e0387ac8c2ab043ce384cdd9b44eee5903145a931d9fc7fc6950d2b74d0f70a35bf5b49f225a656729c6713bffe3aff319135134459d0fe6
@@ -1,3 +1,3 @@
1
1
  module UberSelectRails
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -139,8 +139,8 @@
139
139
  var index = select.selectedIndex
140
140
 
141
141
  if (index == undefined) { return }
142
-
143
142
  uberSearch.searchField.input.val($(select).find('option').eq(index).text())
143
+ uberSearch.searchField.input.select() // Select the text so the user can start typing over it without having to clear
144
144
  uberSearch.searchField.refresh()
145
145
  }
146
146
 
@@ -32,12 +32,18 @@
32
32
  })
33
33
 
34
34
  // When a list item is hovered
35
- $(view).on('mouseenter focus', '.result:not(.disabled)', function(){
35
+ $(view).on('mouseenter', '.result:not(.disabled)', function(){
36
36
  if ($(this).hasClass('highlighted')) { return }
37
37
  unhighlightResults()
38
- highlightResult(this, {scroll: false})
38
+ highlightResult(this, {scroll: false, focus: false})
39
39
  })
40
40
 
41
+ // When a list item receives focus from keyboard
42
+ $(view).on('focus', '.result:not(.disabled)', function(){
43
+ if ($(this).hasClass('highlighted')) { return }
44
+ unhighlightResults()
45
+ highlightResult(this, { scroll: true, focus: false })
46
+ })
41
47
 
42
48
  // HELPER FUNCTIONS
43
49
 
@@ -118,6 +124,8 @@
118
124
  return results().filter('.highlighted')
119
125
  }
120
126
 
127
+ this.highlightedResult = highlightedResult
128
+
121
129
  function selectableResults(){
122
130
  return visibleResults().not('.disabled')
123
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.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen