Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Dialog/Content/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ const Panel = React.forwardRef<PanelRef, PanelProps>((props, ref) => {
contentStyle.height = height;
}
// ================================ Render ================================
const footerNode = footer ? (
const hasFooter = !!footer || footer === 0;
const hasTitle = !!title || title === 0;

const footerNode = hasFooter ? (
<div
className={clsx(`${prefixCls}-footer`, modalClassNames?.footer)}
style={{ ...modalStyles?.footer }}
Expand All @@ -82,7 +85,7 @@ const Panel = React.forwardRef<PanelRef, PanelProps>((props, ref) => {
</div>
) : null;

const headerNode = title ? (
const headerNode = hasTitle ? (
<div
className={clsx(`${prefixCls}-header`, modalClassNames?.header)}
style={{ ...modalStyles?.header }}
Expand Down Expand Up @@ -146,7 +149,7 @@ const Panel = React.forwardRef<PanelRef, PanelProps>((props, ref) => {
<div
key="dialog-element"
role="dialog"
aria-labelledby={title ? ariaId : null}
aria-labelledby={hasTitle ? ariaId : null}
aria-modal="true"
ref={mergedRef}
style={{ ...style, ...contentStyle }}
Expand Down
9 changes: 9 additions & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ describe('dialog', () => {
expect(document.querySelector('.rc-dialog-footer').textContent).toBe('test');
});

it('renders numeric zero title and footer', () => {
render(<Dialog visible title={0} footer={0} />);

const title = document.querySelector<HTMLElement>('.rc-dialog-title');
expect(title).toHaveTextContent('0');
expect(document.querySelector('.rc-dialog-footer')).toHaveTextContent('0');
expect(document.querySelector('.rc-dialog')).toHaveAttribute('aria-labelledby', title!.id);
});

// 失效了,需要修复
it.skip('support input autoFocus', () => {
render(
Expand Down