Skip to content

Commit

Permalink
Remove inverse template for autocomplete as it doesnt accept parameters
Browse files Browse the repository at this point in the history
Inverse component templates can not recieve parameters. This means
there is no access to `searchText` in the inverse block.

- Removed inverse template rendering. Instead try to render
notFoundComponent then default to notFoundMsg
- Update documentation app to reflect these changes

See: emberjs/ember.js#11084
  • Loading branch information
Katelyn Kasperowicz committed Mar 25, 2016
1 parent d283991 commit c73b47c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
12 changes: 4 additions & 8 deletions app/templates/components/paper-autocomplete.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,11 @@

{{else}}
{{#if showLoadingBar}}
{{!-- Render block template, then named component then default --}}
{{#if hasBlock}}
<li>{{yield searchText to="inverse"}}</li>
{{!-- Render named component then default --}}
{{#if notFoundComponent}}
<li>{{component notFoundComponent searchText=searchText}}</li>
{{else}}
{{#if notFoundComponent}}
<li>{{component notFoundComponent searchText=searchText}}</li>
{{else}}
<li>{{notFoundMsg}}</li>
{{/if}}
<li>{{notFoundMsg}}</li>
{{/if}}
{{/if}}
{{/each}}
Expand Down
8 changes: 3 additions & 5 deletions tests/dummy/app/templates/autocomplete.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,11 @@

<h3>Template</h3>
{{#code-block language="handlebars"}}
\{{#paper-autocomplete minLength=0 placeholder="Type e.g. ember, paper, one, two etc." source=arrayOfItems model=fourthModel as |searchText item index|}}}
\{{#paper-autocomplete minLength=0 placeholder="Type e.g. ember, paper, one, two etc." source=arrayOfItems model=fourthModel notFoundMessage="Whoops! Could not find \"%@\." as |searchText item index|}}}
&lt;span class="item-title"&gt;
\{{paper-icon "star"}}
&lt;span&gt; \{{paper-autocomplete-highlight searchText=searchText label=item}} &lt;/span&gt;
&lt;/span&gt;
\{{else}}
Whoops! Could not find "\{{searchText}}".
\{{/paper-autocomplete}}{{/code-block}}

<p>The custom template receives <strong>3 block parameters</strong> (searchText, item and index).
Expand All @@ -192,8 +190,8 @@
<ul>
<li><strong>searchText</strong> This is the original searchText from the user.</li>
<li><strong>item</strong> This is the item directly from the source array. If it is an object you would forexample
need to reference it with <code>\{{item.name}}</code>. Not defined in the inverse template.</li>
<li><strong>index</strong> This is the index of the suggestions that are currently in the list. Not defined in the inverse template.</li>
need to reference it with <code>\{{item.name}}</code>.</li>
<li><strong>index</strong> This is the index of the suggestions that are currently in the list.</li>
</ul>

<h2>Blockless Custom template</h2>
Expand Down

0 comments on commit c73b47c

Please sign in to comment.