Add custom option slot to KDropdownMenu and update documentation#1210
Conversation
|
👋 Thanks for contributing! We will assign a reviewer within the next two weeks. In the meantime, please ensure that:
We'll be in touch! 😊 |
There was a problem hiding this comment.
Pull request overview
This PR exposes UiMenu’s existing scoped option slot through KDropdownMenu, enabling consumers to fully customize how each dropdown item is rendered, and updates the docs + visual tests accordingly.
Changes:
- Forward
#optionscoped slot fromKDropdownMenuto the underlyingUiMenu. - Add a new docs section + example demonstrating custom option rendering.
- Add a new visual regression example for the custom option slot.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/KDropdownMenu/index.vue | Adds forwarding for an option scoped slot into UiMenu. |
| lib/KDropdownMenu/tests/components/KDropdownMenuVisualTest.vue | Registers a new visual test case for the custom option slot example. |
| examples/KDropdownMenu/CustomOption.vue | New example demonstrating #option usage to render icons + styled labels. |
| docs/pages/kdropdownmenu.vue | Adds a “Custom option slot” section and links it in the page sub-nav. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Percy Visual Test ResultsPercy Dashboard: View Detailed Report Environment:
Instructions for Reviewers:
|
|
Thanks @vtushar06! Code changes look good, and visual tests show no regression. Just want to check-in something before merging: @MisRob, There is a rather small problem with just exposing this option as is, the thing is that the node we pass through the slot cannot infer the 100% of the available height, for example, even if we add
To get the full height, we will also need to set a min-height: 40px (or 2.5 rem) to the node that passes through the slot, and this will work fine unless we change the min-height of the UiMenuOption, in which case, we would have an unintended regression that would be difficult to detect. It seems a way to solve this could be by modifying this node to have a class like, so that any node we pass as slot gets the whole height without harcoding the min-height value: .ui-menu-option {
display: flex;
flex-direction: column;
& > * {
flex-grow: 1;
}
}We might want to do this, or any other workaround in the scope of this PR, or if you consider this min height is something that might not change, then it is okay to leave it as it is right now. |
|
Thanks for catching this @AlexVelezLl, You're right our current example hardcodes |
|
Thanks, that's good consideration. I'm fine with that solution @AlexVelezLl :) Within the Keen-related limitations we work with, it feels like the most robust solution we can do now. |
|
As for documentation example code, I recommend we keep it as concise and straightforward as possible, and we show only parts relevant to the new slot. The documentation component provides API to customize what template / script /css we show to a reader, e.g. for template (note the use of Script can be adjusted too. Not that it'd be a big deal at this single place ~ it's just that if we don't consider it for new examples, documentation tends to grow a lot and in my opinion is then harder to navigate & understand. Readers can get full code by clicking GitHub icon if needed. |
|
For the script we should just show: Other 80% of the current content would be irrelevant. @vtushar06 to be clear, you don't need to change how the example component is implemented. This is only about what we show in the docs. You can search for examples how to achieve it or if it's not clear, @AlexVelezLl or I will help :) Thanks! |
|
And finally, please don't use hardcoded |
|
Hi @MisRob, So I've made all the fixes based on the your feedback. The height thing now works way better with flexbox instead of hardcoding pixels, so it won't break if things change. I have switched to KDS color tokens instead of those random hex codes, which keeps everything looking consistent. And the docs example now shows the real way you'd actually use it. |
AlexVelezLl
left a comment
There was a problem hiding this comment.
Thanks a lot @vtushar06! Code changes look good, visual tests show no visual regression, just a couple of observations before merging this PR 👐.
…OnClick to DocsExample
3628160 to
23e1330
Compare
|
Hey @AlexVelezLl and @MisRob, Made all the latest fixes, swapped out the manual div + KIcon + span pattern for KLabeledIcon in both the example component and the docs snippet, which also takes care of the template expression evaluation issue. Also added :hideOnClick="true" to the DocsExample. Let me know if there's anything else to tweak! |
|
Hey @AlexVelezLl, I have added padding and also centered the content which makes examples clean, |
AlexVelezLl
left a comment
There was a problem hiding this comment.
Thanks a lot @vtushar06! LGTM!


Description
Exposes UiMenu's existing option scoped slot through KDropdownMenu, allowing consumers to customize the rendering of each menu item.
Issue addressed
Addresses #1200
Before/after screenshots
Changelog
Steps to test
Testing checklist
Reviewer guidance