Skip to content

Commit

Permalink
feat: Dialog support aria-* in closable
Browse files Browse the repository at this point in the history
  • Loading branch information
kiner-tang committed Feb 29, 2024
1 parent a74b4c7 commit d192ace
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Dialog/Content/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,22 @@ const Panel = React.forwardRef<ContentRef, PanelProps>((props, ref) => {
</div>
);
}
const ariaProps = typeof closable === "object" ? pickAttrs(closable, true) : {};
const mergedClosableIcon = useMemo(() => {
if (typeof closable === "object" && closable.closeIcon) {
return closable.closeIcon;
}
if (closable) {
return closeIcon ?? <span className={`${prefixCls}-close-x`} />;
}
return <span className={`${prefixCls}-close-x`} />;
}, [closable, closeIcon]);


const closableObj =
typeof closable === 'object'
? closable
: closable
? { closeIcon: closeIcon ?? <span className={`${prefixCls}-close-x`} /> }
: {};

const ariaProps = pickAttrs(closableObj, true);

let closer: React.ReactNode;
if (closable) {
closer = (
<button type="button" onClick={onClose} aria-label="Close" {...ariaProps} className={`${prefixCls}-close`}>
{mergedClosableIcon}
{closableObj.closeIcon}
</button>
);
}
Expand Down

0 comments on commit d192ace

Please sign in to comment.