perf: optimize select animate
parent
8ba8983353
commit
7125d84fa2
|
@ -1 +1 @@
|
|||
Subproject commit bef135d01e96fadf80f7a09c7cd26b18aa6d71d8
|
||||
Subproject commit 7f7141a1dd62488287157dee6a1af52716924c62
|
|
@ -135,32 +135,23 @@ const OptionList = defineComponent<OptionListProps, { state?: any }>({
|
|||
);
|
||||
// Auto scroll to item position in single mode
|
||||
|
||||
let timeoutId: number;
|
||||
watch(
|
||||
computed(() => props.open),
|
||||
() => {
|
||||
/**
|
||||
* React will skip `onChange` when component update.
|
||||
* `setActive` function will call root accessibility state update which makes re-render.
|
||||
* So we need to delay to let Input component trigger onChange first.
|
||||
*/
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = setTimeout(() => {
|
||||
if (!props.multiple && props.open && props.values.size === 1) {
|
||||
const value = Array.from(props.values)[0];
|
||||
const index = props.flattenOptions.findIndex(({ data }) => data.value === value);
|
||||
setActive(index);
|
||||
scrollIntoView(index);
|
||||
}
|
||||
});
|
||||
if (!props.multiple && props.open && props.values.size === 1) {
|
||||
const value = Array.from(props.values)[0];
|
||||
const index = props.flattenOptions.findIndex(({ data }) => data.value === value);
|
||||
// setActive(index);
|
||||
scrollIntoView(index);
|
||||
}
|
||||
// Force trigger scrollbar visible when open
|
||||
if (props.open) {
|
||||
nextTick(()=>{
|
||||
nextTick(() => {
|
||||
listRef.current?.scrollTo(undefined);
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
{ immediate: true, flush: 'post' },
|
||||
);
|
||||
|
||||
// ========================== Values ==========================
|
||||
|
|
Loading…
Reference in New Issue