-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
SelectableList not working #2347
Comments
Rookie mistake, I wasn't including the But my issue no. 2 is still valid. |
I can confirm this.. SelectableList doesn't even fire the
Can anyone confirm how to have "dynamic" list items in a selectable list with dividers. |
Well this issue isn't really related to this component alone. It's By Design. The |
I have another remarque. I think that we should drop the support of I'm not sure that we should use the |
@oliviertassinari Actually the issue here is that in order for SelectableContainerEnhance to understand |
@subjectix Ohh, I see, this is not the first time I see this issue. I think that we shouldn't support nested component. That's just to complicate and often doesn't provide any value.
I think that you can. How are you doing it? |
@oliviertassinari That's one way to put it, I can also think of another way to somehow support this. what if we have a HOC that handles all the logic and can be easily customized. If we don't support nested components, then we have to make ListItem highly customizeable. |
@CoveTechnologyAus was almost there: <SelectableList>
{this.data.sites.map((site, index) => {
return (
<div key={...} >
<ListItem value={...} />
{index < this.data.sites.length - 1 ? <ListDivider /> : ''}
</div>
)
})}
</SelectableList> |
Can you try without the |
@prashaantt Ummm... calling map isn't the only way to do this. you can program a little. const length = this.data.sites.length;
const items = [];
for (let i = 0; i < length; i++) {
// Don't push a ListDivider for the first item
if(i !== 0) items.push(<ListDivider key={i} />);
items.push(<ListItem value={this.data.sites[i]} key={i + length} />);
}
return (
<SelectableList>
{items}
</SelectableList>
); Edit: You can also use |
@subjectix Well yes, that's a good work around but a map looks more elegant to me, personally. I have since anyhow programmed around this issue by writing my own |
That's what |
@oliviertassinari Is right, you can use that method to do what you want rather easily. I didn't know about it myself 😅 |
I didn't know of <SelectableList>
{this.items.map(item => {
return (
React.Children.toArray([
<ListDivider />,
<ListItem value={...} />
])
)
})}
</SelectableList> Thank you @oliviertassinari! |
@prashaantt Can we close the issue then? :) |
Yes, but I think this is a frequent use case and should be documented. I'll try sending a PR in a couple of days. |
Alright, feel free to open an PR to add an example. |
Thank You Call-Em-All team for providing the lovely platform of Material Design on top of React I have a question to ask: By any means is it possible to do multiple selection from the list ??
Or will it be better to make a component by own for multiple select purpose. as i guess the Selectable List Component enhance list code is not meant for multiple option I don't want to edit the npm module in my project directory, Can we have a work around for this Looking for some positive suggestion on it . Thanks !! :) |
@diwyanshu The feature you are looking for isn't implemented. |
@diwyanshu any improvements on multi-selectable list? |
I can't get selectable lists to work. After failing to work it out in my own project, I've tried the example straight out of the manual -- the one that looks like this:
A couple observations:
handleUpdateSelectedIndex
isn't getting fired no matter what. So no highlights.ListItem
s must be the direct children of theSelectableList
for it to even highlight the first line upon first render. That means that I can't work out any complex logic inside a map to, let's say, includeListDivider
s for all but the lastListItem
— which needs my map to return theListItem
andListDivider
inside adiv
per iteration.Am I missing something?
The text was updated successfully, but these errors were encountered: