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(popover): support defaultOpen #48481

Merged
merged 9 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions components/popover/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ describe('Popover', () => {
expect(container.querySelector('.ant-popover-inner-content')).toBeTruthy();
});

it('should support defaultOpen', () => {
const { container } = render(
<Popover title="code" defaultOpen>
<span>show me your code</span>
</Popover>,
);
expect(container.querySelector('.ant-popover')).toBeTruthy();
});

it('shows content for render functions', () => {
const renderTitle = () => 'some-title';
const renderContent = () => 'some-content';
Expand Down
2 changes: 1 addition & 1 deletion components/popover/index.tsx
linhf123 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const InternalPopover = React.forwardRef<TooltipRef, PopoverProps>((props, ref)
const rootPrefixCls = getPrefixCls();

const overlayCls = classNames(overlayClassName, hashId, cssVarCls);
const [open, setOpen] = useMergedState(false, {
const [open, setOpen] = useMergedState(undefined, {
linhf123 marked this conversation as resolved.
Show resolved Hide resolved
value: props.open ?? props.visible,
});

Expand Down