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

allow change close aria-label #385

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 3 additions & 2 deletions src/Dialog/Content/Panel.tsx
Expand Up @@ -29,6 +29,7 @@ const Panel = React.forwardRef<ContentRef, PanelProps>((props, ref) => {
ariaId,
footer,
closable,
closeLabel,
closeIcon,
onClose,
children,
Expand Down Expand Up @@ -97,8 +98,8 @@ const Panel = React.forwardRef<ContentRef, PanelProps>((props, ref) => {
let closer: React.ReactNode;
if (closable) {
closer = (
<button type="button" onClick={onClose} aria-label="Close" className={`${prefixCls}-close`}>
{closeIcon || <span className={`${prefixCls}-close-x`} />}
<button type="button" onClick={onClose} title={closeLabel} aria-label={closeLabel ?? "Close"} className={`${prefixCls}-close`}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a prop with closable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean make the closable prop an object with prop label?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it might look like this:
closable: boolean | { icon?: React.ReactNode, ariaLabel?: string } + old closeIcon.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<span className={`${prefixCls}-close-x`} aria-hidden={closeLabel !== undefined ? true : undefined}>{closeIcon}</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to closeIcon looks like a break change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of rendering of the span? Well, from the aria point of view, that change would be correct. The button has already all info for aria, the closeIcon is for visibility only that is why thre is aria-hidden.

It is also possible to keep the line 102 as it was. Then using antd overwrite of closeIcon is a must, to set aria-hidden as long as antd doesn't set aria-hidden on the span automatically.
It would be already an improvement. Should I change the line in my PR?

</button>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/IDialogPropTypes.tsx
Expand Up @@ -58,6 +58,7 @@ export type IDialogPropTypes = {
wrapProps?: any;
getContainer?: GetContainer | false;
closeIcon?: ReactNode;
closeLabel?: string;
modalRender?: (node: ReactNode) => ReactNode;
forceRender?: boolean;
// https://github.com/ant-design/ant-design/issues/19771
Expand Down