Allow overriding the default Suggestion class - #17177
Conversation
|
Thanks! I love PRs that also add documentation! Why the wrapper function however? Why not have the option directly point to the class to use? |
|
I guess that's a remnant of my roundabout way of getting here. I was doing some processing before actually creating the suggestion, but now that I look through my code that's using this PR, it's all just variations of |
Signed-off-by: Steven Hoffman <git@fustrate.com>
|
I just remembered why I did it that way. I have a couple autocompletes that I haven't switched to this branch which use 2 different suggestion types in one field - I'm going to revert back to the original way, convert those fields to make sure it works, and then reopen this PR. |
|
I still don't understand. Wouldn't e.g. |
|
That would work later on, but if the default setting only returns a class, it can't know which Suggestion subclass to return. I'll reopen this PR in the next couple days - I'm currently in the middle of converting a codebase from CoffeeScript to ES6, and I'm just about to the part where dynamic classes will come into play. |
Signed-off-by: Steven Hoffman <git@fustrate.com>
|
Okay, I have no idea why it's working, but with the current no-wrapper PR and a function that returns an instantiated object, it does work. I'm just going to reopen the PR and not think too hard about why |
I'm using Awesomplete for 8 separate dropdowns that need custom
lihtml, and being able to use a custom Suggestion implementation for each item type would really help. Unfortunately, the creation of a Suggestion is hard-coded, so here's a pull request to make it a config option like_.DATAor_.ITEM.I see there's been a previous pull request about spreading list props (#17001) and I think this would help in that area without causing any backwards-compatibility problems or over-complication for people who don't need this feature.