vue-search-select icon indicating copy to clipboard operation
vue-search-select copied to clipboard

Impossible to pass some MultiSelect Props via MultiListSelect

Open birdspider opened this issue 6 years ago • 1 comments

MultiListSelect "inherits" from MultiSelect but only provides

props: {
  options: this.options,
  selectedOptions: this.items,
  isError: this.isError,
  isDisabled: this.isDisabled,
  placeholder: this.placeholder,
  filterPredicate: this.filterPredicate
}

@see: https://github.com/moreta/vue-search-select/blob/master/src/components/lib/MultiListSelect.vue#L9

so its impossible to pass cleanSearch and hideSelectedOptions to MultiSelect via MultiListSelect

is there any particular reason for this?

I ask specificly because I want to disable cleanSearch (dafaults to true).

birdspider avatar Dec 11 '18 15:12 birdspider

my workarounds

ModelListSelectWithFilterPredicate.vue

import { ModelListSelect as ModelLS } from 'vue-search-select'

const tweaks = {
  props: {
    filterPredicate: {
      type: Function,
      default: null
    }
  }
}

const ModelListSelect = {
  extends: ModelLS,
  mixins: [tweaks]
}

export default ModelListSelect

MultiListSelectWithFilterPredicate.vue

import { MultiListSelect as MultiLS, MultiSelect } from 'vue-search-select'

const tweaks = {
  render: function (createElement) {
    return createElement(MultiSelect, {
      props: {
        id: this.id,
        name: this.name,
        options: this.options,
        selectedOptions: this.items,
        isError: this.isError,
        isDisabled: this.isDisabled,
        placeholder: this.placeholder,

        cleanSearch: this.cleanSearch,
        filterPredicate: this.filterPredicate
      },
      on: {
        select: this.onSelect,
        searchchange: (searchText) => this.$emit('searchchange', searchText)
      }
    })
  },
  props: {
    filterPredicate: {
      type: Function,
      default: null
    },
    cleanSearch: {
      type: Boolean,
      default: false
    }
  }
}

const MultiListSelect = {
  extends: MultiLS,
  mixins: [tweaks]
}

export default MultiListSelect

birdspider avatar Mar 06 '19 16:03 birdspider