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

fix(AutoComplete): give minHeight for menu to prevent items clipped #222

Merged
merged 1 commit into from
Jul 15, 2024
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
13 changes: 10 additions & 3 deletions src/components/forms/auto-complete/RuiAutoComplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import RuiIcon from '@/components/icons/Icon.vue';
import RuiChip from '@/components/chips/Chip.vue';
import RuiMenu, { type MenuProps } from '@/components/overlays/menu/Menu.vue';
import RuiProgress from '@/components/progress/Progress.vue';
import type { Ref } from 'vue';

export type T = any;

Expand Down Expand Up @@ -521,6 +520,13 @@ function arrowClicked(event: any) {
}
}

const renderedOptions = ref([]);

const menuMinHeight: ComputedRef<number> = computed(() => {
const renderedOptionsData = get(renderedOptions).slice(0, 5);
return renderedOptionsData.reduce((currentValue, item: typeof RuiButton) => currentValue + item.$el.offsetHeight, 0);
});

defineExpose({
focus: setInputFocus,
setSelectionRange,
Expand Down Expand Up @@ -711,7 +717,7 @@ defineExpose({
<div
v-if="optionsWithSelectedHidden.length > 0"
:class="[css.menu, menuClass]"
:style="{ width: `${width}px`, minWidth: menuWidth }"
:style="{ width: `${width}px`, minWidth: menuWidth, minHeight: `${menuMinHeight}px` }"
v-bind="virtualContainerProps"
@scroll="containerProps.onScroll"
@keydown.up.prevent="moveHighlight(true)"
Expand All @@ -723,7 +729,8 @@ defineExpose({
>
<RuiButton
v-for="({ item, index }) in renderedData"
:key="index"
ref="renderedOptions"
:key="getIdentifier(item)"
:active="isActiveItem(item)"
:size="dense ? 'sm' : undefined"
:value="getIdentifier(item)"
Expand Down
Loading