Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Autocomplete): fix focus in autocomplete #321

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/forms/auto-complete/RuiAutoComplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@

const { focused: activatorFocusedWithin } = useFocusWithin(activator);
const { focused: menuWrapperFocusedWithin } = useFocusWithin(menuWrapperRef);
const { focused: searchInputFocused } = useFocus(textInput);

const anyFocused = logicOr(activatorFocusedWithin, menuWrapperFocusedWithin);
const debouncedAnyFocused = refDebounced(anyFocused, 100);
const recentlyFocused = logicOr(debouncedAnyFocused, anyFocused);
Expand All @@ -108,7 +110,7 @@
const renderedOptions = ref<ComponentPublicInstance[]>([]);

const menuMinHeight = computed<number>(() => {
const renderedOptionsData = get(renderedOptions).slice(0, Math.min(5, get(renderedData).length));

Check warning on line 113 in src/components/forms/auto-complete/RuiAutoComplete.vue

View workflow job for this annotation

GitHub Actions / ci

'renderedData' was used before it was defined
return renderedOptionsData.reduce((currentValue, item) => currentValue + item.$el.offsetHeight, 0);
});

Expand All @@ -116,8 +118,6 @@

const shouldApplyValueAsSearch = computed(() => !(slots.selection || get(multiple) || props.chips));

const { focused: searchInputFocused } = useFocus(textInput);

const internalSearch = ref<string>('');
const debouncedInternalSearch = refDebounced(internalSearch, 100);

Expand Down Expand Up @@ -306,7 +306,6 @@
else {
await nextTick(() => {
set(isOpen, false);
set(searchInputFocused, false);
});
if (get(shouldApplyValueAsSearch))
updateInternalSearch(getText(val));
Expand All @@ -316,7 +315,7 @@
set(value, [val]);
}

if (!skipRefocused && get(multiple))
if (!skipRefocused)
set(searchInputFocused, true);
}

Expand Down Expand Up @@ -621,7 +620,7 @@
</div>
</RuiChip>
<div
v-else-if="(multiple || slots['selection.prepend'] || slots.selection) && (!searchInputFocused || multiple)"
v-else-if="multiple || ((!searchInputFocused) && (slots['selection.prepend'] || slots.selection))"
class="flex"
>
<slot
Expand Down Expand Up @@ -658,6 +657,7 @@
variant="text"
icon
size="sm"
tabindex="-1"
color="error"
class="group-hover:!visible"
:class="[$style.clear, anyFocused && '!visible', {
Expand Down Expand Up @@ -798,7 +798,7 @@
&.readonly {
@apply opacity-80 pointer-events-none cursor-default bg-gray-50;
}

Check warning on line 801 in src/components/forms/auto-complete/RuiAutoComplete.vue

View workflow job for this annotation

GitHub Actions / ci

File has too many lines (988). Maximum allowed is 800
&.outlined {
@apply border-none hover:border-none;

Expand Down
Loading