Skip to content

Commit

Permalink
fix(Dropdown): 修改展开位置在下方时,关闭动画异常问题 (#1813)
Browse files Browse the repository at this point in the history
* fix(Dropdown): 修改展开位置在下方时,关闭动画异常问题

* fix(EditableSelect): 远程搜索时,loading结束再显示无数据
  • Loading branch information
xingyan95 authored Mar 28, 2024
1 parent db83658 commit 578f03f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/devui-vue/devui/dropdown/src/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default defineComponent({
props,
emit,
});
useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
useDropdown(id, visible, isOpen, origin, dropdownRef, emit);
const { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange } = useOverlayProps(props, currentPosition, isOpen);

watch(overlayShowValue, (overlayShowValueVal) => {
Expand Down
15 changes: 0 additions & 15 deletions packages/devui-vue/devui/dropdown/src/use-dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,8 @@ export function useDropdown(
isOpen: Ref<boolean>,
origin: Ref<HTMLElement | undefined>,
dropdownRef: Ref<HTMLElement | undefined>,
popDirection: Ref<string>,
emit: EmitEvent
): void {
const calcPopDirection = (dropdownEl: HTMLElement) => {
const elementHeight = dropdownEl.offsetHeight;
const bottomDistance = window.innerHeight - (origin.value as HTMLElement).getBoundingClientRect().bottom;
const isBottomEnough = bottomDistance >= elementHeight;
if (!isBottomEnough) {
popDirection.value = 'top';
} else {
popDirection.value = 'bottom';
}
};

watch(
visible,
(newVal, oldVal) => {
Expand Down Expand Up @@ -153,9 +141,6 @@ export function useDropdown(
}
}
}
if (dropdownEl) {
calcPopDirection(dropdownEl);
}
});
onMounted(() => {
dropdownMap.set(id, { toggleEl: origin.value });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default defineComponent({

// 渲染options
const renderOption = () => {
if (props.options.length === 0) {
if (props.options.length === 0 && !select.loading.value) {
return <li class={ns.em('item', 'no-data-tip')}>{slots.noResultItem ? slots.noResultItem() : emptyText.value}</li>;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/devui-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-devui",
"version": "1.6.4-select.0",
"version": "1.6.5",
"license": "MIT",
"description": "DevUI components based on Vite and Vue3",
"keywords": [
Expand Down

0 comments on commit 578f03f

Please sign in to comment.