Skip to content

Commit

Permalink
fix: allow dynamically loading selectable options
Browse files Browse the repository at this point in the history
  • Loading branch information
Merlin Flach authored and OrbisK committed Jun 27, 2022
1 parent 982558d commit 41f2b16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Multiselect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
>
<ul :class="classList.options" data-cy="optionList">
<li
v-for="(option) in shownOptions"
v-for="(option) in selectOptions"
:key=option.value
:class="classList.option(option)"
data-cy="option"
Expand Down
7 changes: 2 additions & 5 deletions src/utils/useOptions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import Option from "../types/option.type";
import _ from "lodash";
import {computed, ref, toRefs, watch} from "vue";
import {computed, toRefs, watch} from "vue";

export default function useOptions(props: any, context: any, dependencies: any) {
const {selectOptions, closeOnSelect, multiple} = toRefs(props)
const {closeOnSelect, multiple} = toRefs(props)

const selectedValues = dependencies.selectedValues
const closeDropdown = dependencies.closeDropdown

const shownOptions = ref<Option[]>(selectOptions.value)

const selectedOptions = computed<Option | Option[]>(() => {
let selected = []
for (const option of props.selectOptions) {
Expand Down Expand Up @@ -102,7 +100,6 @@ export default function useOptions(props: any, context: any, dependencies: any)

return {
selectedOptions,
shownOptions,
isSelected,
handleOptionClick
}
Expand Down

0 comments on commit 41f2b16

Please sign in to comment.