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: context issues for Space.Compact #38870

Merged
merged 2 commits into from Nov 22, 2022
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
41 changes: 22 additions & 19 deletions components/drawer/index.tsx
Expand Up @@ -13,6 +13,7 @@ import type { DrawerPanelProps } from './DrawerPanel';

// CSSINJS
import useStyle from './style';
import { NoCompactStyle } from '../space/Compact';

const SizeTypes = tuple('default', 'large');
type sizeType = typeof SizeTypes[number];
Expand Down Expand Up @@ -120,25 +121,27 @@ function Drawer(props: DrawerProps) {

// =========================== Render ===========================
return wrapSSR(
<NoFormStyle status override>
<RcDrawer
prefixCls={prefixCls}
onClose={onClose}
maskMotion={maskMotion}
motion={panelMotion}
{...rest}
open={open ?? visible}
mask={mask}
push={push}
width={mergedWidth}
height={mergedHeight}
rootClassName={drawerClassName}
getContainer={getContainer}
afterOpenChange={afterOpenChange ?? afterVisibleChange}
>
<DrawerPanel prefixCls={prefixCls} {...rest} onClose={onClose} />
</RcDrawer>
</NoFormStyle>,
<NoCompactStyle>
<NoFormStyle status override>
<RcDrawer
prefixCls={prefixCls}
onClose={onClose}
maskMotion={maskMotion}
motion={panelMotion}
{...rest}
open={open ?? visible}
mask={mask}
push={push}
width={mergedWidth}
height={mergedHeight}
rootClassName={drawerClassName}
getContainer={getContainer}
afterOpenChange={afterOpenChange ?? afterVisibleChange}
>
<DrawerPanel prefixCls={prefixCls} {...rest} onClose={onClose} />
</RcDrawer>
</NoFormStyle>
</NoCompactStyle>,
);
}

Expand Down
3 changes: 2 additions & 1 deletion components/dropdown/dropdown.tsx
Expand Up @@ -13,6 +13,7 @@ import getPlacements from '../_util/placements';
import { cloneElement } from '../_util/reactNode';
import { tuple } from '../_util/type';
import warning from '../_util/warning';
import { NoCompactStyle } from '../space/Compact';
import DropdownButton from './dropdown-button';
import useStyle from './style';

Expand Down Expand Up @@ -264,7 +265,7 @@ const Dropdown: DropdownInterface = (props) => {
);
}}
>
{overlayNode}
<NoCompactStyle>{overlayNode}</NoCompactStyle>
</OverrideProvider>
);
};
Expand Down
18 changes: 11 additions & 7 deletions components/input-number/index.tsx
Expand Up @@ -11,7 +11,7 @@ import DisabledContext from '../config-provider/DisabledContext';
import type { SizeType } from '../config-provider/SizeContext';
import SizeContext from '../config-provider/SizeContext';
import { FormItemInputContext, NoFormStyle } from '../form/context';
import { useCompactItemContext } from '../space/Compact';
import { NoCompactStyle, useCompactItemContext } from '../space/Compact';
import { cloneElement } from '../_util/reactNode';
import type { InputStatus } from '../_util/statusUtils';
import { getMergedStatus, getStatusClassNames } from '../_util/statusUtils';
Expand Down Expand Up @@ -188,15 +188,19 @@ const InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props,
<div className={mergedGroupClassName} style={props.style}>
<div className={mergedWrapperClassName}>
{addonBeforeNode && (
<NoFormStyle status override>
{addonBeforeNode}
</NoFormStyle>
<NoCompactStyle>
<NoFormStyle status override>
{addonBeforeNode}
</NoFormStyle>
</NoCompactStyle>
)}
{cloneElement(element, { style: null, disabled: mergedDisabled })}
{addonAfterNode && (
<NoFormStyle status override>
{addonAfterNode}
</NoFormStyle>
<NoCompactStyle>
<NoFormStyle status override>
{addonAfterNode}
</NoFormStyle>
</NoCompactStyle>
)}
</div>
</div>
Expand Down
55 changes: 30 additions & 25 deletions components/modal/Modal.tsx
Expand Up @@ -5,6 +5,7 @@ import type { ButtonProps, LegacyButtonType } from '../button/button';
import type { DirectionType } from '../config-provider';
import { ConfigContext } from '../config-provider';
import { NoFormStyle } from '../form/context';
import { NoCompactStyle } from '../space/Compact';
import { getTransitionName } from '../_util/motion';
import { canUseDocElement } from '../_util/styleChecker';
import warning from '../_util/warning';
Expand Down Expand Up @@ -195,31 +196,35 @@ const Modal: React.FC<ModalProps> = (props) => {
}

return wrapSSR(
<NoFormStyle status override>
<Dialog
width={width}
{...restProps}
getContainer={
getContainer === undefined ? (getContextPopupContainer as getContainerFunc) : getContainer
}
prefixCls={prefixCls}
rootClassName={hashId}
wrapClassName={wrapClassNameExtended}
footer={renderFooter({
...props,
onOk: handleOk,
onCancel: handleCancel,
})}
visible={open ?? visible}
mousePosition={restProps.mousePosition ?? mousePosition}
onClose={handleCancel}
closeIcon={renderCloseIcon(prefixCls, closeIcon)}
focusTriggerAfterClose={focusTriggerAfterClose}
transitionName={getTransitionName(rootPrefixCls, 'zoom', props.transitionName)}
maskTransitionName={getTransitionName(rootPrefixCls, 'fade', props.maskTransitionName)}
className={classNames(hashId, className)}
/>
</NoFormStyle>,
<NoCompactStyle>
<NoFormStyle status override>
<Dialog
width={width}
{...restProps}
getContainer={
getContainer === undefined
? (getContextPopupContainer as getContainerFunc)
: getContainer
}
prefixCls={prefixCls}
rootClassName={hashId}
wrapClassName={wrapClassNameExtended}
footer={renderFooter({
...props,
onOk: handleOk,
onCancel: handleCancel,
})}
visible={open ?? visible}
mousePosition={restProps.mousePosition ?? mousePosition}
onClose={handleCancel}
closeIcon={renderCloseIcon(prefixCls, closeIcon)}
focusTriggerAfterClose={focusTriggerAfterClose}
transitionName={getTransitionName(rootPrefixCls, 'zoom', props.transitionName)}
maskTransitionName={getTransitionName(rootPrefixCls, 'fade', props.maskTransitionName)}
className={classNames(hashId, className)}
/>
</NoFormStyle>
</NoCompactStyle>,
);
};

Expand Down