fix(popover): support defaultOpen (#48481)

* fix(popover): support defaultOpen

* chore: add test

* fix: remove test code

* fix: open use default value

* chore: Coding style

* chore: devtool add warning

* fix: remove warning

* fix: Remove unused dependencies

---------

Co-authored-by: linhf123 <wb-lhf780012@antgroup.com>
Co-authored-by: afc163 <afc163@gmail.com>
This commit is contained in:
@linhf2024 2024-04-17 11:34:11 +08:00 committed by GitHub
parent 4b2a94e383
commit a512f81222
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -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';

View File

@ -60,6 +60,7 @@ const InternalPopover = React.forwardRef<TooltipRef, PopoverProps>((props, ref)
const overlayCls = classNames(overlayClassName, hashId, cssVarCls);
const [open, setOpen] = useMergedState(false, {
value: props.open ?? props.visible,
defaultValue: props.defaultOpen ?? props.defaultVisible,
});
const settingOpen = (