-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A workaround for repeat.for and paper-tabs, paper-menu, iron-selector, paper-listbox... #23
Comments
This is great, thanks! Would you mind opening a PR to add the code replacing the default behavior and/or the au-select attribute? |
Okay, I will try. |
Today paper-tabs and repeat.for work without au-select. I can't reproduce the issue and I'm confused. |
Here is a simple skeleton of selection with repeat.for. Although this is an example of paper-dropdown-menu, the pattern is common to others such as paper-tabs. It shows a list of country names. You will have countryCode after selection.
|
Hmm, was there an Aurelia upgrade? |
I have just sent a PR. Please merge it, if it is good. |
Merged! |
It's not working for me (I'm using fd482e6):
I checked and markup<paper-dropdown-menu>
<paper-listbox class="dropdown-content" selected="0" au-select selectable=".item">
<div>
<paper-item repeat.for="i of 10" class="item">${i}</paper-item>
</div>
</paper-listbox>
</paper-dropdown-menu> |
Should've been fixed by #25 |
I'm using the latest commit and it's not fixed... now that I notice, the files in Yep, that was it. Building the source fixes it. |
After some testing I must say that this is not a good workaround... In the case of The only good solution I found at the moment is to use Polymer's own repeater: <paper-tabs>
<template is="dom-repeat" items.bind="items">
<paper-tab>{{item}}</paper-tab>
</template>
</paper-tabs> |
@wc-matteo, I confirmed your code works. It solves some annoying issues such as font size of tabs in the original workaround. Great invention. I am not familiar with Polymer's data biding. How do you use it with Aurelia's data binding? For example, a tab includes tag usually. With the following code, item.title appears in the tabs, but does not work as a link.
|
All credits go to: aurelia/binding#262 I'm not familiar with Polymer's data binding myself, but I found this. In short, the syntax is: |
I tried the href$="{{item.href}}" and confirmed it does not work. The fact you found is strange. |
When you have a trouble with paper-tabs, paper-radio-button, paper-menu, paper-listbox... anything that uses iron-selector inside to select an item, try this workaround.
iron-selector selects one from child elements but ignores child child elements inside a child element. (It seems not always, though.)
In the following example, the is sometimes ignored because it is not a direct child element of the .
When you use repeat.for, Aurelia wraps things in a element. So, no generated element can be selected. (See #17 for more detail.)
A workaround is au-select attribute that gathers all child elements and child child elements under or similar elements.
In the following example, paper-tabs works au-select with
Give selectable="CSS selector" to iron-selector and give class="CSS selector" to selectable elements. (note: * selectable=".selectable_item" requires ".")
This is a TypeScript version of the au-select custom attribute.
This is a JavaScript version.
The above code was borrowed from PolymerElements/iron-selector#42.
Or, the following code can be added to main.ts to replace the default behavior, if you don't want to use the au-select attribute.
The text was updated successfully, but these errors were encountered: