Skip to content

Commit

Permalink
fix(components): [select] support dynamic value for option
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Aug 5, 2022
1 parent ad1967a commit f0fb631
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/components/select/src/option.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ export default defineComponent({
const { visible, hover } = toRefs(states)
const vm = getCurrentInstance().proxy
const key = (vm as unknown as SelectOptionProxy).value
select.onOptionCreate(vm as unknown as SelectOptionProxy)
onBeforeUnmount(() => {
const key = (vm as unknown as SelectOptionProxy).value
const { selected } = select
const selectedOptions = select.props.multiple ? selected : [selected]
const doesSelected = selectedOptions.some((item) => {
Expand Down
4 changes: 4 additions & 0 deletions packages/components/select/src/useOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export function useOption(props, states) {
() => props.value,
(val, oldVal) => {
const { remote, valueKey } = select.props
if (!Object.is(val, oldVal)) {
select.onOptionDestroy(oldVal, instance.proxy)
select.onOptionCreate(instance.proxy)
}
if (!props.created && !remote) {
if (
valueKey &&
Expand Down

0 comments on commit f0fb631

Please sign in to comment.