Skip to content

Commit

Permalink
Merge branch 'xomaczar-fix-autocomplete-open-with-select'
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelcobain committed Dec 16, 2016
2 parents f4d8921 + a6ad7f2 commit 8992b9d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 17 deletions.
4 changes: 2 additions & 2 deletions addon/components/paper-chips.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default Component.extend({
}

// Keep track of the autocomplete, so we can force it to close when navigating to chips.
if (isEmpty(this.get('autocomplete')) && input.is('.ember-power-select-typeahead-input')) {
if (isEmpty(this.get('autocomplete')) && input.is('.ember-paper-autocomplete-search-input')) {
this.set('autocomplete', autocomplete);
}

Expand Down Expand Up @@ -194,7 +194,7 @@ export default Component.extend({
let select = this.get('autocomplete');
let input = this.getInput();

if (input.is('.ember-power-select-typeahead-input') && isPresent(select)) {
if (input.is('.ember-paper-autocomplete-search-input') && isPresent(select)) {
// Reset the underlying ember-power-select so that it's ready for another selection.
input.val('');
select.actions.search('');
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/paper-autocomplete-trigger.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{else}}
<input type="search"
value={{text}}
class="ember-power-select-typeahead-input ember-power-select-search-input flex"
class="ember-paper-autocomplete-search-input flex"
placeholder={{readonly placeholder}}
oninput={{action "handleInputLocal"}}
onchange={{action "handleInputLocal"}}
Expand Down
30 changes: 26 additions & 4 deletions app/templates/components/paper-chips.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<md-chips-wrap class="md-chips {{if (and (not readOnly) isFocused) 'md-focused'}}" tabindex="-1" onkeydown={{action 'keyDown'}} onfocus={{action 'chipsFocus'}} onblur={{action 'chipsBlur'}}>
<md-chips-wrap
class="md-chips {{if (and (not readOnly) isFocused) 'md-focused'}}"
tabindex="-1"
onkeydown={{action 'keyDown'}}
onfocus={{action 'chipsFocus'}}
onblur={{action 'chipsBlur'}}>
{{#each content as |item index|}}
<md-chip class="md-chip md-default-theme {{if readOnly 'md-readonly'}} {{if (eq activeChip index) 'md-focused'}}">
<div class="md-chip-content" tabindex="-1" aria-hidden="true">
Expand All @@ -10,7 +15,7 @@
</div>
<div class="md-chip-remove-container">
{{#unless readOnly}}
<button class="md-chip-remove" {{action (action removeItem item)}} type="button" aria-hidden="true" tabindex="-1">
<button class="md-chip-remove" onclick={{action removeItem item}} type="button" aria-hidden="true" tabindex="-1">
{{paper-icon icon="clear" size=18}}
<span class="md-visually-hidden"> Remove </span>
</button>
Expand All @@ -24,15 +29,32 @@
{{#unless readOnly}}
<div class="md-chip-input-container">
{{#if (or requireMatch options)}}
{{#paper-autocomplete closeOnSelect=true onBlur=(action 'inputBlur') onSelectionChange=(action 'autocompleteChange') onSearchTextChange=(action 'searchTextChange') onFocus=(action 'inputFocus') onOpen=(action 'inputFocus') onCreate=(action 'addItem') placeholder=placeholder options=options searchField=searchField noMatchesMessage=noMatchesMessage as |item|}}
{{#paper-autocomplete
options=options
closeOnSelect=true
placeholder=placeholder
searchField=searchField
noMatchesMessage=noMatchesMessage
onBlur=(action 'inputBlur')
onSelectionChange=(action 'autocompleteChange')
onSearchTextChange=(action 'searchTextChange')
onFocus=(action 'inputFocus')
onOpen=(action 'inputFocus')
onCreate=(action 'addItem') as |item|}}
{{#if hasBlock}}
{{yield item}}
{{else}}
<span>{{item}}</span>
{{/if}}
{{/paper-autocomplete}}
{{else}}
{{input tabindex="0" placeholder=placeholder aria-label="Add Tag" value=newChipValue focus-in="inputFocus" focus-out="inputBlur" enter=(action 'addItem' newChipValue)}}
{{input tabindex="0"
placeholder=placeholder
aria-label="Add Tag"
value=newChipValue
focus-in="inputFocus"
focus-out="inputBlur"
enter=(action 'addItem' newChipValue)}}
{{/if}}
</div>
{{/unless}}
Expand Down
24 changes: 14 additions & 10 deletions app/templates/components/paper-select.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,20 @@
to=(readonly destination)
searchEnabled=searchEnabled
dropdown=publicAPI as |content|}}
{{component beforeOptionsComponent
extra=(readonly extra)
listboxId=(readonly optionsId)
onInput=(action "onInput")
onKeydown=(action "onKeydown")
searchEnabled=(readonly searchEnabled)
onFocus=(action "onFocus")
onBlur=(action "deactivate")
searchPlaceholder=(readonly searchPlaceholder)
select=(readonly publicAPI)}}
{{#if searchEnabled}}
{{component beforeOptionsComponent
extra=(readonly extra)
listboxId=(readonly optionsId)
onInput=(action "onInput")
onKeydown=(action "onKeydown")
searchEnabled=(readonly searchEnabled)
onFocus=(action "onFocus")
onBlur=(action "deactivate")
searchPlaceholder=(readonly searchPlaceholder)
select=(readonly publicAPI)
}}
{{/if}}

{{#if mustShowSearchMessage}}
{{component searchMessageComponent
searchMessage=(readonly searchMessage)
Expand Down

0 comments on commit 8992b9d

Please sign in to comment.