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(date-picker): when default slot is a comment node, date-picker will not display #4105

Merged
merged 1 commit into from
May 23, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions components/_util/props-util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ export function isEmptyElement(c) {
);
}

export function isEmptySlot(c) {
return !c || c().every(isEmptyElement);
}

export function isStringElement(c) {
return c && c.type === Text;
}
Expand Down
3 changes: 2 additions & 1 deletion components/date-picker/createPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { hasProp, getOptionProps, getComponent, isValidElement } from '../_util/
import { cloneElement } from '../_util/vnode';
import { formatDate } from './utils';
import { getDataAndAriaProps } from '../_util/util';
import { isEmptySlot } from '../_util/props-util';

export interface PickerProps {
value?: moment.Moment;
Expand Down Expand Up @@ -255,7 +256,7 @@ export default function createPicker<P>(
>
<VcDatePicker
{...vcDatePickerProps}
v-slots={{ default: input, ...$slots }}
v-slots={{ ...$slots, default: isEmptySlot($slots.default) ? input : $slots.default }}
></VcDatePicker>
</span>
);
Expand Down