Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 61670ba

Browse files
lukicenturikelsos
authored andcommitted
fix(AutoComplete): give min height for menu to prevent items clipped
1 parent f1461e8 commit 61670ba

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/components/forms/auto-complete/RuiAutoComplete.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import RuiIcon from '@/components/icons/Icon.vue';
66
import RuiChip from '@/components/chips/Chip.vue';
77
import RuiMenu, { type MenuProps } from '@/components/overlays/menu/Menu.vue';
88
import RuiProgress from '@/components/progress/Progress.vue';
9-
import type { Ref } from 'vue';
109
1110
export type T = any;
1211
@@ -521,6 +520,13 @@ function arrowClicked(event: any) {
521520
}
522521
}
523522
523+
const renderedOptions = ref([]);
524+
525+
const menuMinHeight: ComputedRef<number> = computed(() => {
526+
const renderedOptionsData = get(renderedOptions).slice(0, 5);
527+
return renderedOptionsData.reduce((currentValue, item: typeof RuiButton) => currentValue + item.$el.offsetHeight, 0);
528+
});
529+
524530
defineExpose({
525531
focus: setInputFocus,
526532
setSelectionRange,
@@ -711,7 +717,7 @@ defineExpose({
711717
<div
712718
v-if="optionsWithSelectedHidden.length > 0"
713719
:class="[css.menu, menuClass]"
714-
:style="{ width: `${width}px`, minWidth: menuWidth }"
720+
:style="{ width: `${width}px`, minWidth: menuWidth, minHeight: `${menuMinHeight}px` }"
715721
v-bind="virtualContainerProps"
716722
@scroll="containerProps.onScroll"
717723
@keydown.up.prevent="moveHighlight(true)"
@@ -723,7 +729,8 @@ defineExpose({
723729
>
724730
<RuiButton
725731
v-for="({ item, index }) in renderedData"
726-
:key="index"
732+
ref="renderedOptions"
733+
:key="getIdentifier(item)"
727734
:active="isActiveItem(item)"
728735
:size="dense ? 'sm' : undefined"
729736
:value="getIdentifier(item)"

0 commit comments

Comments
 (0)