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

fix: Modal static func #47010

Merged
merged 3 commits into from
Jan 17, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions components/config-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/modal/__tests__/confirm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions components/modal/confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const ConfirmDialogWrapper: React.FC<ConfirmDialogProps> = (props) => {
const runtimeLocale = getConfirmLocale();

const config = useContext(ConfigContext);
const rootPrefixCls = customizePrefixCls || getRootPrefixCls() || config.getPrefixCls();
zombieJ marked this conversation as resolved.
Show resolved Hide resolved
const rootPrefixCls = getRootPrefixCls() || config.getPrefixCls();
// because Modal.config set rootPrefixCls, which is different from other components
const prefixCls = customizePrefixCls || `${rootPrefixCls}-modal`;

Expand Down Expand Up @@ -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();

Expand Down