Skip to content

Commit cff3c37

Browse files
docs: add example for avoiding duplicate text using item slot (#21989)
Co-authored-by: Andrew Henry <[email protected]> Resolves #19396
1 parent c7e093f commit cff3c37

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

packages/docs/src/examples/v-menu/prop-positioningmenu.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
{ title: 'Remove', prependIcon: 'mdi-trash-can-outline', code: 'delete' },
5353
]
5454
55-
async function show(evt) {
55+
async function show (evt) {
5656
if (showMenu.value) {
5757
showMenu.value = false
58-
await new Promise(r => setTimeout(r, 100))
58+
await new Promise(resolve => setTimeout(resolve, 100))
5959
}
6060
menuTarget.value = evt.target.closest('.v-icon-btn')
6161
showMenu.value = true
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<v-app>
3+
<v-container>
4+
<v-select v-model="model" :items="items">
5+
<template v-slot:item="{ props, item }">
6+
<v-list-item v-bind="props" :title="null">
7+
<v-list-item-title>{{ item.title }}</v-list-item-title>
8+
</v-list-item>
9+
</template>
10+
</v-select>
11+
</v-container>
12+
</v-app>
13+
</template>
14+
15+
<script>
16+
export default {
17+
data: () => ({
18+
items: ['Foo', 'Bar', 'Fizz', 'Buzz'],
19+
model: 'Foo',
20+
}),
21+
}
22+
</script>

packages/docs/src/pages/en/components/selects.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ You can specify the specific properties within your items array that correspond
8989

9090
<ExamplesExample file="v-select/prop-custom-title-and-value" />
9191

92+
When customizing items with the `item` slot, you should disable the default `title` prop rendering to avoid duplicate text.
93+
You can do this by setting `:title="null"` on `v-list-item`.
94+
95+
<ExamplesExample file="v-select/prop-avoid-duplicate-text" />
96+
9297
#### Menu props
9398

9499
Custom props can be passed directly to `v-menu` using **menu-props** prop. In this example a scrim as added to the select and the menu closes when you scroll.

0 commit comments

Comments
 (0)