Skip to content

Commit 08fc45f

Browse files
authored
Merge pull request #6574 from avalonmediasystem/typeahead_blur
Close typeahead dropdown when input loses focus
2 parents 2ebbcf4 + 4151f73 commit 08fc45f

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2011-2025, The Trustees of Indiana University and Northwestern
3+
* University. Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
*
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software distributed
11+
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
13+
* specific language governing permissions and limitations under the License.
14+
* --- END LICENSE_HEADER BLOCK ---
15+
*/
16+
17+
import Autocomplete from '@github/auto-complete-element/dist/autocomplete.js'
18+
19+
Autocomplete.prototype.open = function(event) {
20+
const isHidden = this.results.popover ? !this.results.matches(':popover-open') : this.results.hidden
21+
if (isHidden) {
22+
this.combobox.start()
23+
if (this.results.popover) {
24+
this.results.showPopover()
25+
} else {
26+
this.results.hidden = false
27+
}
28+
}
29+
this.container.open = true
30+
this.interactingWithList = false
31+
};

app/javascript/packs/application.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ import Search from '../components/Search';
4040
import MediaObjectRamp from '../components/MediaObjectRamp';
4141
import ReactButtonContainer from '../components/ReactButtonContainer';
4242
import PlaylistRamp from '../components/PlaylistRamp';
43-
import '@github/auto-complete-element'
43+
import '../auto-complete-open.js';
44+
import '@github/auto-complete-element';
4445

4546
ReactOnRails.register({
4647
CollectionList,

0 commit comments

Comments
 (0)