mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(components): [select] Slot default invoked outside of the render (#23232)
* fix(components): [select] Slot default invoked outside of the render * test: fix expect error --------- Co-authored-by: rzzf <cszhjh@gmail.com>
This commit is contained in:
@@ -62,7 +62,7 @@ describe('options', () => {
|
||||
default: () =>
|
||||
samples.map((_, i) => <ElOptionStub label={getLabel(i)} />),
|
||||
})
|
||||
expect(mockWarn).toHaveBeenCalled()
|
||||
expect(mockWarn).not.toHaveBeenCalled()
|
||||
vi.resetAllMocks()
|
||||
await nextTick()
|
||||
})
|
||||
@@ -85,7 +85,7 @@ describe('options', () => {
|
||||
</ElOptionGroupStub>
|
||||
)),
|
||||
})
|
||||
expect(spy).toHaveBeenCalled()
|
||||
expect(spy).not.toHaveBeenCalled()
|
||||
vi.resetAllMocks()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -521,7 +521,12 @@ export default defineComponent({
|
||||
})
|
||||
}
|
||||
watch(
|
||||
() => [slots.default?.(), modelValue.value],
|
||||
() => [
|
||||
props.persistent || API.expanded.value || !slots.default
|
||||
? undefined
|
||||
: slots.default?.(),
|
||||
modelValue.value,
|
||||
],
|
||||
() => {
|
||||
// When persistent is false and the dropdown is closed, the menu is unmounted.
|
||||
// We should always re-hydrate option data from slots so labels stay in sync
|
||||
|
||||
Reference in New Issue
Block a user