Skip to content
Closed
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
20 changes: 12 additions & 8 deletions src/calendar/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import props from './props';
import { useTNodeJSX } from '../hooks/tnode';
import TCalendarTemplate from './template';
import { usePrefixClass } from '../hooks/useClass';
import type { CalendarTrigger } from './type';

const { prefix } = config;

Expand Down Expand Up @@ -34,21 +35,24 @@ export default defineComponent({
context.emit('update:visible', v);
};

const onPopupVisibleChange = (v: boolean) => {
if (!v) {
props.onClose?.('overlay');
} else {
nextTick(() => {
selectedValueIntoView();
});
}
const onPopupVisibleChange = (v: boolean, trigger: CalendarTrigger) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得问题出在 popup , visible 从 false --> true 时,onVisibleChange 事件没有正确触发。 建议优化 popup ,确保 popup 组件会在 visible 状态变化时(无论是外部控制还是内部操作)都能按预期触发 onVisibleChange 回调

if (!v) props.onClose?.(trigger);
context.emit('update:visible', v);
};

onMounted(() => {
if (!props.usePopup) selectedValueIntoView();
});

watch(
() => props.visible,
(val) => {
if (val) {
nextTick(() => selectedValueIntoView());
}
},
);

watch(
() => props.value,
(val) => {
Expand Down
Loading