@@ -46,10 +46,10 @@ const selected = defineModel<OptionValue | OptionValue[]>({
46
46
validator : (value , _props ) => _props .isMulti ? Array .isArray (value ) : ! Array .isArray (value ),
47
47
});
48
48
49
- const container = useTemplateRef (" container" );
50
- const input = useTemplateRef (" input" );
51
- const menu = useTemplateRef (" menu" );
52
- const indicators = useTemplateRef (" indicators" );
49
+ const containerRef = useTemplateRef (" container" );
50
+ const inputRef = useTemplateRef (" input" );
51
+ const menuRef = useTemplateRef (" menu" );
52
+ const indicatorsRef = useTemplateRef (" indicators" );
53
53
54
54
const search = ref (" " );
55
55
const menuOpen = ref (false );
@@ -109,8 +109,8 @@ function openMenu() {
109
109
focusedOption .value = props .options .findIndex ((option ) => ! option .disabled );
110
110
}
111
111
112
- if (input .value ) {
113
- input .value .focus ();
112
+ if (inputRef .value ) {
113
+ inputRef .value .focus ();
114
114
}
115
115
116
116
emit (" menuOpened" );
@@ -132,7 +132,7 @@ function toggleMenu() {
132
132
};
133
133
134
134
function handleControlClick(event : MouseEvent ) {
135
- if (indicators .value ?.container && ! indicators .value .container .contains (event .target as Node )) {
135
+ if (indicatorsRef .value ?.containerRef && ! indicatorsRef .value .containerRef .contains (event .target as Node )) {
136
136
openMenu ();
137
137
}
138
138
};
@@ -157,8 +157,8 @@ const setOption = (option: GenericOption) => {
157
157
closeMenu ();
158
158
}
159
159
160
- if (input .value ) {
161
- input .value .blur ();
160
+ if (inputRef .value ) {
161
+ inputRef .value .blur ();
162
162
}
163
163
};
164
164
@@ -181,8 +181,8 @@ const clear = () => {
181
181
182
182
closeMenu ();
183
183
184
- if (input .value ) {
185
- input .value .blur ();
184
+ if (inputRef .value ) {
185
+ inputRef .value .blur ();
186
186
}
187
187
};
188
188
@@ -278,14 +278,14 @@ const handleInputKeydown = (e: KeyboardEvent) => {
278
278
};
279
279
280
280
const handleClickOutside = (event : MouseEvent ) => {
281
- if (container .value && ! container .value .contains (event .target as Node )) {
281
+ if (containerRef .value && ! containerRef .value .contains (event .target as Node )) {
282
282
closeMenu ();
283
283
}
284
284
};
285
285
286
286
const calculateMenuPosition = () => {
287
- if (container .value ) {
288
- const rect = container .value .getBoundingClientRect ();
287
+ if (containerRef .value ) {
288
+ const rect = containerRef .value .getBoundingClientRect ();
289
289
290
290
return {
291
291
left: ` ${rect .x }px ` ,
@@ -455,7 +455,7 @@ onBeforeUnmount(() => {
455
455
:aria-label =" aria?.labelledby"
456
456
:aria-multiselectable =" isMulti"
457
457
:style =" {
458
- width: props.teleport ? `${container ?.getBoundingClientRect().width}px` : '100%',
458
+ width: props.teleport ? `${containerRef ?.getBoundingClientRect().width}px` : '100%',
459
459
top: props.teleport ? calculateMenuPosition().top : 'unset',
460
460
left: props.teleport ? calculateMenuPosition().left : 'unset',
461
461
}"
@@ -466,7 +466,7 @@ onBeforeUnmount(() => {
466
466
v-for =" (option, i) in availableOptions"
467
467
:key =" i"
468
468
type =" button"
469
- :menu =" menu "
469
+ :menu =" menuRef "
470
470
:index =" i"
471
471
:is-focused =" focusedOption === i"
472
472
:is-selected =" option.value === selected"
0 commit comments