Skip to content

Commit cc35671

Browse files
committed
fix: select focus logic #3099
1 parent 2e61e9c commit cc35671

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

components/vc-select/hooks/useDelayReset.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { onBeforeUpdate, Ref, ref } from 'vue';
1+
import { onMounted, Ref, ref } from 'vue';
22

33
/**
44
* Similar with `useLock`, but this hook will always execute last value.
@@ -14,12 +14,11 @@ export default function useDelayReset(
1414
window.clearTimeout(delay);
1515
};
1616

17-
onBeforeUpdate(() => {
17+
onMounted(() => {
1818
cancelLatest();
1919
});
2020
const delaySetBool = (value: boolean, callback: () => void) => {
2121
cancelLatest();
22-
2322
delay = window.setTimeout(() => {
2423
bool.value = value;
2524
if (callback) {

components/vc-select/utils/valueUtil.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { warning } from '../../vc-util/warning';
2-
import { VNodeChild } from 'vue';
2+
import { isVNode, VNodeChild } from 'vue';
33
import {
44
OptionsType as SelectOptionsType,
55
OptionData,
@@ -163,7 +163,15 @@ export const getLabeledValue: GetLabeledValue<FlattenOptionData[]> = (
163163
};
164164

165165
function toRawString(content: VNodeChild): string {
166-
return toArray(content).join('');
166+
return toArray(content)
167+
.map(item => {
168+
if (isVNode(item)) {
169+
return item?.el?.innerText || item?.el?.wholeText;
170+
} else {
171+
return '';
172+
}
173+
})
174+
.join('');
167175
}
168176

169177
/** Filter single option if match the search text */
@@ -177,7 +185,6 @@ function getFilterFunction(optionFilterProp: string) {
177185
.toLowerCase()
178186
.includes(lowerSearchText);
179187
}
180-
181188
// Option value search
182189
const rawValue = option[optionFilterProp];
183190
const value = toRawString(rawValue).toLowerCase();

0 commit comments

Comments
 (0)