收口轻量支付弹窗与个人中心图标按钮
UnifiedModal 新增无头部模式并补齐对应可访问性测试 RpgEntryHomeView 的支付结果提示、支付确认遮罩与个人中心顶栏图标按钮改用共享组件 更新 PlatformUiKit 收口计划与 .hermes 决策记录
This commit is contained in:
@@ -63,6 +63,28 @@ test('supports disabling escape close while keeping the custom close button chro
|
||||
expect(screen.getByRole('dialog', { name: '个人中心弹窗' })).toBeTruthy();
|
||||
});
|
||||
|
||||
test('supports headerless dialogs while preserving the accessible name', () => {
|
||||
render(
|
||||
<UnifiedModal
|
||||
open
|
||||
title="支付成功"
|
||||
description="账户状态已刷新"
|
||||
onClose={() => {}}
|
||||
showHeader={false}
|
||||
showCloseButton={false}
|
||||
portal={false}
|
||||
>
|
||||
<div>窗口内容</div>
|
||||
</UnifiedModal>,
|
||||
);
|
||||
|
||||
const dialog = screen.getByRole('dialog', { name: '支付成功' });
|
||||
|
||||
expect(dialog).toBeTruthy();
|
||||
expect(screen.queryByRole('button', { name: '关闭' })).toBeNull();
|
||||
expect(screen.getByText('窗口内容')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('respects closeDisabled for every default close path', () => {
|
||||
const onClose = vi.fn();
|
||||
render(
|
||||
|
||||
@@ -25,6 +25,7 @@ type UnifiedModalProps = {
|
||||
onClose: () => void;
|
||||
variant?: UnifiedModalVariant;
|
||||
size?: UnifiedModalSize;
|
||||
showHeader?: boolean;
|
||||
closeDisabled?: boolean;
|
||||
closeOnBackdrop?: boolean;
|
||||
closeOnEscape?: boolean;
|
||||
@@ -86,6 +87,7 @@ function UnifiedModalContent({
|
||||
onClose,
|
||||
variant = 'platform',
|
||||
size = 'md',
|
||||
showHeader = true,
|
||||
closeDisabled = false,
|
||||
closeOnBackdrop = true,
|
||||
closeOnEscape = true,
|
||||
@@ -173,42 +175,51 @@ function UnifiedModalContent({
|
||||
<div
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby={titleId}
|
||||
aria-labelledby={showHeader ? titleId : undefined}
|
||||
aria-label={showHeader ? undefined : title}
|
||||
aria-describedby={description ? descriptionId : undefined}
|
||||
className={joinClassNames(panelClasses, sizeClassName, panelClassName)}
|
||||
style={getPanelStyle(variant, panelStyle)}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
>
|
||||
<div className={joinClassNames(headerClasses, headerClassName)}>
|
||||
<div className="min-w-0">
|
||||
<div
|
||||
id={titleId}
|
||||
className={joinClassNames(titleClasses, titleClassName)}
|
||||
>
|
||||
{title}
|
||||
</div>
|
||||
{description ? (
|
||||
{showHeader ? (
|
||||
<div className={joinClassNames(headerClasses, headerClassName)}>
|
||||
<div className="min-w-0">
|
||||
<div
|
||||
id={descriptionId}
|
||||
className={joinClassNames(
|
||||
descriptionClasses,
|
||||
descriptionClassName,
|
||||
)}
|
||||
id={titleId}
|
||||
className={joinClassNames(titleClasses, titleClassName)}
|
||||
>
|
||||
{description}
|
||||
{title}
|
||||
</div>
|
||||
{description ? (
|
||||
<div
|
||||
id={descriptionId}
|
||||
className={joinClassNames(
|
||||
descriptionClasses,
|
||||
descriptionClassName,
|
||||
)}
|
||||
>
|
||||
{description}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
{showCloseButton ? (
|
||||
<PlatformModalCloseButton
|
||||
label={closeLabel}
|
||||
onClick={onClose}
|
||||
disabled={closeDisabled}
|
||||
variant={closeVariant ?? (isPixel ? 'pixel' : 'platformIcon')}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
{showCloseButton ? (
|
||||
<PlatformModalCloseButton
|
||||
label={closeLabel}
|
||||
onClick={onClose}
|
||||
disabled={closeDisabled}
|
||||
variant={closeVariant ?? (isPixel ? 'pixel' : 'platformIcon')}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
<div className={joinClassNames(bodyClasses, bodyClassName)}>
|
||||
{/* 无头部弹窗仍需要把描述挂到 aria-describedby,避免只剩可访问名称没有上下文。 */}
|
||||
{!showHeader && description ? (
|
||||
<div id={descriptionId} className="sr-only">
|
||||
{description}
|
||||
</div>
|
||||
) : null}
|
||||
{children}
|
||||
</div>
|
||||
{footer ? (
|
||||
|
||||
Reference in New Issue
Block a user