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

🗣️ Screen reader support for reactive output changes #2757

Merged
merged 4 commits into from
Jan 3, 2024
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
16 changes: 14 additions & 2 deletions frontend/components/CellOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const prettyAssignee = (assignee) =>
export class CellOutput extends Component {
constructor() {
super()
this.state = {}
this.state = {
output_changed_once: false,
}

this.old_height = 0
// @ts-ignore Is there a way to use the latest DOM spec?
Expand All @@ -60,6 +62,12 @@ export class CellOutput extends Component {
return last_run_timestamp !== this.props.last_run_timestamp || sanitize_html !== this.props.sanitize_html
}

componentDidUpdate(old_props) {
if (this.props.last_run_timestamp !== old_props.last_run_timestamp) {
this.setState({ output_changed_once: true })
}
}

componentDidMount() {
this.resize_observer.observe(this.base)
}
Expand All @@ -84,8 +92,12 @@ export class CellOutput extends Component {
})}
translate=${allow_translate}
mime=${this.props.mime}
aria-live=${this.state.output_changed_once ? "polite" : "off"}
aria-atomic="true"
aria-relevant="all"
aria-label=${this.props.rootassignee == null ? "Result of unlabeled cell:" : `Result of variable ${this.props.rootassignee}:`}
>
<assignee translate=${false}>${prettyAssignee(this.props.rootassignee)}</assignee>
<assignee aria-hidden="true" translate=${false}>${prettyAssignee(this.props.rootassignee)}</assignee>
<${OutputBody} ...${this.props} />
</pluto-output>
`
Expand Down