Skip to content

Commit

Permalink
fix: Modal static func (ant-design#47010)
Browse files Browse the repository at this point in the history
* fix: Modal static func

* chore: clean up

* chore: clean up
  • Loading branch information
zombieJ authored Jan 17, 2024
1 parent 85fb745 commit be058e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
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();
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

0 comments on commit be058e4

Please sign in to comment.