fix: Modal static func (#47010)

* fix: Modal static func

* chore: clean up

* chore: clean up
This commit is contained in:
二货爱吃白萝卜 2024-01-17 17:40:04 +08:00 committed by GitHub
parent 85fb745bd1
commit be058e4794
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View File

@ -266,6 +266,12 @@ const setGlobalConfig = (props: GlobalConfigProps) => {
};
export const globalConfig = () => ({
getPrefixCls: (suffixCls?: string, customizePrefixCls?: string) => {
if (customizePrefixCls) {
return customizePrefixCls;
}
return suffixCls ? `${getGlobalPrefixCls()}-${suffixCls}` : getGlobalPrefixCls();
},
getIconPrefixCls: getGlobalIconPrefixCls,
getRootPrefixCls: () => {
// If Global prefixCls provided, use this

View File

@ -468,7 +468,7 @@ describe('Modal.confirm triggers callbacks correctly', () => {
expect($$('.custom-modal-wrap')).toHaveLength(1);
expect($$('.custom-modal-confirm')).toHaveLength(1);
expect($$('.custom-modal-confirm-body-wrapper')).toHaveLength(1);
expect($$('.custom-modal-btn')).toHaveLength(2);
expect($$('.ant-btn')).toHaveLength(2);
});
it('should be Modal.confirm without mask', async () => {

View File

@ -29,7 +29,7 @@ const ConfirmDialogWrapper: React.FC<ConfirmDialogProps> = (props) => {
const runtimeLocale = getConfirmLocale();
const config = useContext(ConfigContext);
const rootPrefixCls = customizePrefixCls || getRootPrefixCls() || config.getPrefixCls();
const rootPrefixCls = getRootPrefixCls() || config.getPrefixCls();
// because Modal.config set rootPrefixCls, which is different from other components
const prefixCls = customizePrefixCls || `${rootPrefixCls}-modal`;
@ -98,7 +98,7 @@ export default function confirm(config: ModalFuncProps) {
* Sync render blocks React event. Let's make this async.
*/
timeoutId = setTimeout(() => {
const rootPrefixCls = global.getRootPrefixCls();
const rootPrefixCls = global.getPrefixCls(undefined, getRootPrefixCls());
const iconPrefixCls = global.getIconPrefixCls();
const theme = global.getTheme();