|
| 1 | +<script lang="ts"> |
| 2 | +import { defineComponent } from 'vue' |
| 3 | +import ShikiStyle from '../../components/shiki_style.vue' |
| 4 | +
|
| 5 | +import SlimSelect from '@/slim-select' |
| 6 | +
|
| 7 | +export default defineComponent({ |
| 8 | + name: 'KeepSearch', |
| 9 | + mounted() { |
| 10 | + // Single |
| 11 | + new SlimSelect({ |
| 12 | + select: this.$refs.keepSearchSingle as HTMLSelectElement, |
| 13 | + settings: { |
| 14 | + keepSearch: true |
| 15 | + } |
| 16 | + }) |
| 17 | +
|
| 18 | + // Multiple |
| 19 | + new SlimSelect({ |
| 20 | + select: this.$refs.keepSearchMulti as HTMLSelectElement, |
| 21 | + settings: { |
| 22 | + keepSearch: true |
| 23 | + } |
| 24 | + }) |
| 25 | + }, |
| 26 | + components: { |
| 27 | + ShikiStyle |
| 28 | + } |
| 29 | +}) |
| 30 | +</script> |
| 31 | + |
| 32 | +<template> |
| 33 | + <div id="keepSearch" class="content"> |
| 34 | + <h2 class="header">keepSearch</h2> |
| 35 | + <p> |
| 36 | + The keepSearch setting controls whether the search input text is preserved when the dropdown closes. When enabled, |
| 37 | + any text entered in the search field will remain when you reopen the dropdown, allowing you to continue your |
| 38 | + previous search. |
| 39 | + </p> |
| 40 | + <p> |
| 41 | + By default, the search field is cleared each time the dropdown closes. Enabling this setting is useful when users |
| 42 | + need to maintain their last search and results, such as when picking multiple selections in a multi-select |
| 43 | + dropdown. |
| 44 | + </p> |
| 45 | + |
| 46 | + <div class="row" style="padding: 0 0 var(--spacing-half) 0"> |
| 47 | + <select ref="keepSearchSingle"> |
| 48 | + <option value="dog">Dog</option> |
| 49 | + <option value="cat">Cat</option> |
| 50 | + <option value="bird">Bird</option> |
| 51 | + <option value="fish">Fish</option> |
| 52 | + <option value="hamster">Hamster</option> |
| 53 | + <option value="rabbit">Rabbit</option> |
| 54 | + </select> |
| 55 | + |
| 56 | + <select ref="keepSearchMulti" multiple> |
| 57 | + <option value="dog">Dog</option> |
| 58 | + <option value="cat">Cat</option> |
| 59 | + <option value="bird">Bird</option> |
| 60 | + <option value="fish">Fish</option> |
| 61 | + <option value="hamster">Hamster</option> |
| 62 | + <option value="rabbit">Rabbit</option> |
| 63 | + </select> |
| 64 | + </div> |
| 65 | + |
| 66 | + <ShikiStyle language="javascript"> |
| 67 | + <pre> |
| 68 | + new SlimSelect({ |
| 69 | + select: '#selectElement', |
| 70 | + settings: { |
| 71 | + keepSearch: true |
| 72 | + } |
| 73 | + }) |
| 74 | + </pre> |
| 75 | + </ShikiStyle> |
| 76 | + </div> |
| 77 | +</template> |
0 commit comments