fix: default cssvarkey only picked when component themeconfig && parent th… (#50377)

* fix: default cssvarkey picked when component themeconfig && parent themeconfig not setted at the same time

只有当组件theme和parentTheme都没有设置cssvarkey时,才使用默认的cssvarkey

Signed-off-by: zhuzhu_coder <zjczoo@gmail.com>

* Apply suggestions from code review

Signed-off-by: afc163 <afc163@gmail.com>

* Update components/config-provider/hooks/useTheme.ts

Signed-off-by: afc163 <afc163@gmail.com>

* Update components/config-provider/hooks/useTheme.ts

Signed-off-by: afc163 <afc163@gmail.com>

---------

Signed-off-by: zhuzhu_coder <zjczoo@gmail.com>
Signed-off-by: afc163 <afc163@gmail.com>
Co-authored-by: afc163 <afc163@gmail.com>
This commit is contained in:
zhuzhu_coder 2025-01-21 12:07:59 +08:00 committed by GitHub
parent b0308b60a5
commit 3284536605
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -64,7 +64,9 @@ export default function useTheme(
prefix: config?.prefixCls, // Same as prefixCls by default
...(typeof parentThemeConfig.cssVar === 'object' ? parentThemeConfig.cssVar : {}),
...(typeof themeConfig.cssVar === 'object' ? themeConfig.cssVar : {}),
key: (typeof themeConfig.cssVar === 'object' && themeConfig.cssVar?.key) || cssVarKey,
key: (typeof themeConfig.cssVar === 'object' && themeConfig.cssVar?.key)
|| (typeof parentThemeConfig.cssVar === 'object' && parentThemeConfig.cssVar?.key)
|| cssVarKey,
};
// Base token