Skip to content

Commit

Permalink
fix(popover): support defaultOpen (#48481)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people committed Apr 17, 2024
1 parent 4b2a94e commit a512f81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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
1 change: 1 addition & 0 deletions components/popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down

0 comments on commit a512f81

Please sign in to comment.