Skip to content

Commit

Permalink
fix(dialog): the style and className of dialog props pass to bad …
Browse files Browse the repository at this point in the history
…element (#2639)

- #2619
  • Loading branch information
NWYLZW authored Jan 11, 2024
1 parent d164c94 commit 208118d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const Dialog = forwardRef<DialogInstance, DialogProps>((originalProps, ref) => {
const [local] = useLocaleReceiver('dialog');

const {
className,
dialogClassName,
style,
width,
mode,
Expand Down Expand Up @@ -192,7 +194,7 @@ const Dialog = forwardRef<DialogInstance, DialogProps>((originalProps, ref) => {
<Portal attach={attach} ref={portalRef}>
<div
ref={wrapRef}
className={classNames(props.className, `${componentCls}__ctx`, `${componentCls}__${mode}`, {
className={classNames(className, `${componentCls}__ctx`, `${componentCls}__${mode}`, {
[`${componentCls}__ctx--fixed`]: !showInAttachedElement,
[`${componentCls}__ctx--absolute`]: showInAttachedElement,
})}
Expand Down Expand Up @@ -224,6 +226,7 @@ const Dialog = forwardRef<DialogInstance, DialogProps>((originalProps, ref) => {
<DialogCard
ref={dialogCardRef}
{...restState}
className={dialogClassName}
style={{ ...style, width: parseValueToPx(width || style?.width) }}
onConfirm={onConfirm}
onCancel={handleCancel}
Expand Down
9 changes: 7 additions & 2 deletions src/dialog/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import { TNode, Styles, AttachNode } from '../common';
import { MouseEvent, KeyboardEvent } from 'react';

export interface TdDialogProps extends TdDialogCardProps {
/**
* 弹框元素类名,示例:'t-class-dialog-first t-class-dialog-second'
* @default ''
*/
dialogClassName?: string;
/**
* 对话框挂载的节点。数据类型为 String 时,会被当作选择器处理,进行节点查询。示例:'body' 或 () => document.body
*/
Expand Down Expand Up @@ -156,12 +161,12 @@ export interface DialogOptions extends Omit<TdDialogProps, 'attach'> {
*/
attach?: AttachNode;
/**
* 弹框类名,示例:'t-class-dialog-first t-class-dialog-second'
* ctx 弹框顶层元素类名,示例:'t-class-dialog-ctx-first t-class-dialog-ctx-second'
* @default ''
*/
className?: string;
/**
* 弹框 style 属性,输入 [CSSStyleDeclaration.cssText](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssText)
* 弹框顶层元素 style 属性,输入 [CSSStyleDeclaration.cssText](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/cssText)
*/
style?: Styles;
}
Expand Down

0 comments on commit 208118d

Please sign in to comment.