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

Add screen reader support to Start Dialog #1567

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 63 additions & 56 deletions apps/client/src/components/Dialog/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,65 +58,72 @@ export default function ResponsiveDialog(props) {
typeof onVisibilityChanged === "function" && onVisibilityChanged(open);

return (
<Dialog
aria-labelledby="responsive-dialog-title"
fullScreen={fullScreen}
onClose={handleClose}
open={open}
// Must stop event-bubbling. Otherwise the parent element in react can be dragged etc.
onMouseDown={(e) => {
e.stopPropagation();
}}
>
{headerText && (
<DialogTitle id="responsive-dialog-title">{headerText}</DialogTitle>
)}
<DialogContent>
{children}
{useLegacyNonMarkdownRenderer === true ? (
<LegacyNonMarkdownRenderer text={text} />
) : (
<ReactMarkdown
remarkPlugins={[gfm]} // GitHub Formatted Markdown adds support for Tables in MD
rehypePlugins={rehypePlugins} // Needed to parse HTML, activated in admin
components={customComponentsForReactMarkdown} // Custom renderers for components, see definition in components
children={text} // Our MD, as a text string
/>
open && (
<Dialog
aria-labelledby="responsive-dialog-title"
aria-describedby="responsive-dialog-content"
fullScreen={fullScreen}
onClose={handleClose}
open={open}
// Must stop event-bubbling. Otherwise the parent element in react can be dragged etc.
onMouseDown={(e) => {
e.stopPropagation();
}}
>
{headerText && (
<DialogTitle id="responsive-dialog-title">{headerText}</DialogTitle>
)}
<DialogContent id="responsive-dialog-content">
{children}
{useLegacyNonMarkdownRenderer === true ? (
<LegacyNonMarkdownRenderer text={text} />
) : (
<ReactMarkdown
remarkPlugins={[gfm]} // GitHub Formatted Markdown adds support for Tables in MD
rehypePlugins={rehypePlugins} // Needed to parse HTML, activated in admin
components={customComponentsForReactMarkdown} // Custom renderers for components, see definition in components
children={text} // Our MD, as a text string
/>
)}

{prompt && (
<form
noValidate
autoComplete="off"
onSubmit={(e) => {
e.preventDefault();
props.onClose(promptText);
return false;
}}
>
<TextField
id="prompt-text"
label=""
value={promptText}
onChange={(e) => {
setPromptText(e.target.value);
{prompt && (
<form
noValidate
autoComplete="off"
onSubmit={(e) => {
e.preventDefault();
props.onClose(promptText);
return false;
}}
margin="normal"
autoFocus={true}
/>
</form>
)}
</DialogContent>
<DialogActions>
<Button onClick={handleClose} variant={primaryButtonVariant || "text"}>
{buttonText}
</Button>
{abortText && (
<Button onClick={handleAbort} sx={{ color: "text.primary" }}>
{abortText}
>
<TextField
id="prompt-text"
label=""
value={promptText}
onChange={(e) => {
setPromptText(e.target.value);
}}
margin="normal"
autoFocus={true}
/>
</form>
)}
</DialogContent>
<DialogActions>
<Button
onClick={handleClose}
variant={primaryButtonVariant || "text"}
sx={{ color: "text.primary" }}
>
{buttonText}
</Button>
)}
</DialogActions>
</Dialog>
{abortText && (
<Button onClick={handleAbort} sx={{ color: "text.primary" }}>
{abortText}
</Button>
)}
</DialogActions>
</Dialog>
)
);
}