Skip to content
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 src/Dialog/Content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
}

function onPrepare() {
if (!dialogRef.current?.nativeElement) {
return;
}

const elementOffset = offset(dialogRef.current.nativeElement);

setTransformOrigin(
Expand Down
12 changes: 12 additions & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,18 @@ describe('dialog', () => {
document.querySelector<HTMLElement>('.rc-dialog').style['transform-origin'],
).toBeTruthy();
});

it('should not throw error when nativeElement is not available', () => {
expect(() => {
global.onAppearPrepare?.();
}).not.toThrow();

render(<Dialog visible />);

expect(() => {
global.onAppearPrepare?.();
}).not.toThrow();
});
});

it('can get dom element before dialog first show when forceRender is set true ', () => {
Expand Down
Loading