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

在next中同时使用了Drawer和Popover组件并设置了自定义主题后,Drawer样式失效了 #49853

Open
Kiyumi-v opened this issue Jul 13, 2024 · 8 comments

Comments

@Kiyumi-v
Copy link

Kiyumi-v commented Jul 13, 2024

Reproduction link

https://github.com/Kiyumi-v/AntdRegistryProblem

Steps to reproduce

在同时使用AntdRegistry、设置layer、设置自定义主题后,同时使用Drawer和Popover组件后,在页面上发现Drawer样式丢失。

What is expected?

期望Drawer正常显示

What is actually happening?

Drawer样式丢失

Environment Info
antd 5.19.1
React react 18.3.3
System macOS 14.5 (23F79)
Browser Chrome 126.0.6478.127
@Kiyumi-v
Copy link
Author

this is how Drawer display now
WechatIMG21

this is Drawer style
WechatIMG22

@ethos-vitalii
Copy link

ethos-vitalii commented Aug 24, 2024

I have a similar problem. Whenever I use Popover that wraps a Button, some random styles are lost on the page. In my case, it's positioning of the icon inside of the circular Progress. Switching to Tooltip fixed the issue. Disabling layer also fixes the issue.

I use Next.js, so might be related to SSR. When I switch theme, it causes global re-render of the page and all styles are coming back and it starts working. So client-side reinitialization helps. It is really annoying as now I need to create our custom implementation of Popover based on Tooltip to make it work.

@Kiyumi-v
Copy link
Author

Kiyumi-v commented Aug 25, 2024 via email

@github-actions github-actions bot removed the Inactive label Aug 25, 2024
@ethos-vitalii
Copy link

ethos-vitalii commented Aug 25, 2024

yeah, this problem is in css-in-js of antd. I rewrite nextjs-registry, fixed the styles problem.

2024年8月25日 06:51,ethos-vitalii @.***> 写道: I have a similar problem. Whenever I use Popover that wraps a Button, some random styles are lost on the page. In my case, it's positioning an icon inside of the circular Progress. Switching to Tooltip fixed the issue. Also, disabling layer also fixes the issue. I use Next.js, so might be related to SSR. When I switch theme, it causes global re-render of the page and all styles are coming back and it starts working. — Reply to this email directly, view it on GitHub <#49853 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASG3TUK2FLKGY5YCMS47FRLZTEE7ZAVCNFSM6AAAAABKZ7YGA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYGU3DIMRWGA. You are receiving this because you authored the thread.

What did you change in nextjs-registry to fix the problem? Mind sharing your AntdRegistry? If that's the problem with @ant-design/nextjs-registry, we can report it to https://github.com/ant-design/nextjs-registry

@Kiyumi-v
Copy link
Author

Kiyumi-v commented Aug 25, 2024 via email

@Kiyumi-v
Copy link
Author

Kiyumi-v commented Aug 25, 2024 via email

@Kiyumi-v
Copy link
Author

Kiyumi-v commented Aug 25, 2024 via email

@ethos-vitalii
Copy link

Ah, yes. Indeed, it fixes the issue and I can confirm that CSS is wrong. Here's a snippet of incorrect CSS:

.css-var-R2cq.ant-popover {
  --ant-popover-title-min-width: 177px;
  --ant-popover-z-index-popup: 1030;
  --ant-popover-arrow-shadow-width: 8.970562748477143px;
  --ant-popover-arrow-path: path('M 0 8 A 4 4 0 0 0 2.82842712474619 6.82842712474619 L 6.585786437626905 3.0710678118654755 A 2 2 0 0 1 9.414213562373096 3.0710678118654755 L 13.17157287525381 6.82842712474619 A 4 4 0 0 0 16 8 Z');
  --ant-popover-arrow-polygon: polygon(1.6568542494923806px 100%, 50% 1.6568542494923806px, 14.34314575050762px 100%, 1.6568542494923806px 100%);
  --ant-popover-arrow-offset-horizontal: 12px;
  --ant-popover-arrow-offset-vertical: 8px;
  --ant-popover-inner-padding: 12px;
  --ant-popover-title-margin-bottom: 8px;
  --ant-popover-title-padding: 0px;
  --ant-popover-title-border-bottom: none;
  --ant-popover-inner-content-padding: 0px;
}

@layer antd@layer antd {
  .ant-progress {
    font-family: var(--ant-font-family);
    font-size: var(--ant-font-size);
    box-sizing: border-box;
  }

...

So the bug must be in antd or @ant-design/cssinjs because it generates an invalid CSS for Popover, it adds an extra @layer after Popover styles.

I'll apply your workaround for now but it would be nice to get it fixing.
Let me try to report this issue to @ant-design/cssinjs. Thanks @Kiyumi-v for figuring it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants