-
Notifications
You must be signed in to change notification settings - Fork 261
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
Introducing Action Button for Dropdown #56
Conversation
Had to fix an ugly typo ^^ |
@MadSpindel Hey :) Just wanted to ask how the chances are that this gets accepted and released anytime soon. Don't want to stress but I need this feature quite soon. If this takes longer or gets rejected I'd just stick with my fork but I just wanted to ask first. |
I am not sure if I understand the use case for this? Do you have any real life-examples of other sites using this technique? |
@MadSpindel Of course. There are many. If you scroll up on github and use the search to look for repositories. The search buttons
would be our action-buttons, the existing repositories would be our items. The difference here is of course that this is not in the context of an editor - that's why we cannot solve some problems by just using different URLs. But also besides my own use-case which is a real life example on its own (but similar to the ones below), one could think of the following scenarios:
and there would be one more thing which I think should be possible:
|
Thank you @silentsnooc. I will try to review this today or tomorrow 👍 |
@MadSpindel Awesome! :) I am already using this in my project (from my fork of course) and so far I did not have any troubles. I hope it stays like that. ^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am missing documentation about beforeInsert() and showDenotationChar in the README.
I updated |
@silentsnooc I am not sure if this is the right way. What I would like to see - I guess - is making renderList/renderItem more flexible (e.g. enable action buttons). Because I think we want something like a custom callback for each item in the list. Maybe something like "onSelect"? |
@MadSpindel Hm, what do you have in mind? I don't see a straight forward way to make Could you elaborate what you have in mind? |
Sure, will try :) I think selectItem() should call something like this.options.onSelect(item). Default should be to insert the item, but making it an option make it possible for you to do different things based on item type (like a action button). In a way, that is what you are trying to do with your code but maybe not as clear? |
@MadSpindel Okay but how would we prevent the insertion of an item? And does |
Since the insert will be in the this.options.onSelect, we can prevent the insertion by overriding the logic in the onSelect with our own custom onSelect. |
Do you mean something like this: onSelect(item, insertItem) {
if (item.hasOwnProperty('query') {
// Make server call and then insertItem(item);
} else {
insertItem(item);
}
}, And the default would be of course: this.options = {
// ..
onSelect(item, insertItem) {
insertItem(item);
},
// ..
} |
Yes, but default should only be insertItem without any |
Alright - I can make these changes if you want :) |
Sure, or if you make a new PR, it doesn't matter to me 👍 |
I'd just make those changes and push to this PR if that's okay with you :) |
For
Is that okay or would you use a different wording/explanation? |
Sounds good to me 👍 |
@MadSpindel I pushed all changes of my last commit e98be50 :) |
@MadSpindel I just noticed that the dropdown is transparent: has this always been the case or did I break something? |
I applied the requested changes. Only thing missing would be the integration for a custom class for styling and last but not least a rebuild for |
Alright, I made the changes regarding the style classes and updated the example in the |
I can fix |
@MadSpindel Awesome! Thanks for accepting this PR :) |
Thank you for excellent job! 💯 |
@MadSpindel Hi, do you have a demo working example of this? |
This PR would make it possible to
beforeInsert()
as callback to get information which item has been selectedshowDenotationChar
(defaulttrue
) to switch off rendering or the denotation char if neededNothing should change for how
quill-mention
works at the moment. my changes "should" not break anything already working.I have extended the demo with an example:
See also #54