-
Notifications
You must be signed in to change notification settings - Fork 50
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
Fix DialogContent requires a DialogTitle warning #62
base: main
Are you sure you want to change the base?
Fix DialogContent requires a DialogTitle warning #62
Conversation
@@ -108,7 +109,9 @@ export const Modal = forwardRef<HTMLDivElement, ModalProps>(({ | |||
ref={ref} | |||
className={classNames(styles.wrapper, className)} | |||
{...restProps} | |||
aria-describedby={undefined} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thank you for your PR.
aria-describedby
should be undefined without it. You also rewrite it for restProps in case someone wants to pass it, did you do it on purpose?
It worked with me, thank for your solution, I need to patch-package it currently. |
same error |
This issue still persist in
and
perhaps reexporting styled anatomy parts from radix can help user to fix it by they own? |
Hello. Any news? |
Here is my fix:
import {
Modal as TGModal,
ModalProps as TGModalProps,
VisuallyHidden,
} from '@telegram-apps/telegram-ui';
import { DialogDescription, DialogTitle } from '@radix-ui/react-dialog';
export interface ModalProps extends TGModalProps {
/**
* Accessibility text added for aria-describedby
*/
descriptionText?: string;
/**
* Accessibility text added for aria-labelledby
*/
titleText?: string;
}
export const Modal: FC<ModalProps> = ({
descriptionText = 'Modal Description',
titleText = 'Modal title',
children,
...props
}) => {
return (
<TGModal
{...props}
>
<VisuallyHidden>
<DialogDescription>{descriptionText}</DialogDescription>
<DialogTitle>{titleText}</DialogTitle>
</VisuallyHidden>
{children}
</TGModal>
);
};
|
This should fix #55
RadixUI which is used by Vaul, which is used by this library is quite opinionated when it comes to a11y.
It requires to explicitly set
<Dialog.Title>
(for this library it is<Drawer.TItle>
) and<Dialog.Description>
Here is reference issue in Radix: radix-ui/primitives#2986
--
In this PR I just utilize
VisuallyHidden
and hack my way thorough this warning. The only thing that seems to be added to final DOM is this:--
Thanks for the lib by the way :-) using it to craft a small pet project, works like charm :-)