Skip to content

Fix screen reader features #2694

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

Merged
merged 2 commits into from
Jan 25, 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
28 changes: 12 additions & 16 deletions client/modules/Preview/EmbedFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,27 +224,23 @@ function injectLocalFiles(files, htmlFile, options) {
resolveScripts(sketchDoc, resolvedFiles);
resolveStyles(sketchDoc, resolvedFiles);

const accessiblelib = sketchDoc.createElement('script');
accessiblelib.setAttribute(
'src',
'https://cdn.jsdelivr.net/gh/processing/p5.accessibility@0.1.1/dist/p5-accessibility.js'
);
const accessibleOutputs = sketchDoc.createElement('section');
accessibleOutputs.setAttribute('id', 'accessible-outputs');
accessibleOutputs.setAttribute('aria-label', 'accessible-output');
if (textOutput || gridOutput) {
sketchDoc.body.appendChild(accessibleOutputs);
sketchDoc.body.appendChild(accessiblelib);
const scriptElement = sketchDoc.createElement('script');
let textCode = '';
if (textOutput) {
const textSection = sketchDoc.createElement('section');
textSection.setAttribute('id', 'textOutput-content');
sketchDoc.getElementById('accessible-outputs').appendChild(textSection);
textCode = 'if (!this._accessibleOutputs.text) this.textOutput();';
}
let gridCode = '';
if (gridOutput) {
const gridSection = sketchDoc.createElement('section');
gridSection.setAttribute('id', 'tableOutput-content');
sketchDoc.getElementById('accessible-outputs').appendChild(gridSection);
gridCode = 'if (!this._accessibleOutputs.grid) this.gridOutput();';
}
const fxn = `p5.prototype.ensureAccessibleCanvas = function _ensureAccessibleCanvas() {
${textCode}
${gridCode}
};
p5.prototype.registerMethod('afterSetup', p5.prototype.ensureAccessibleCanvas);`;
scriptElement.innerHTML = fxn;
sketchDoc.head.appendChild(scriptElement);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think there's any harm in putting this at the end of the body in case people rearrange the imports of their sketch and import p5 in the body too?

Copy link
Collaborator

@lindapaiste lindapaiste Dec 6, 2023

Choose a reason for hiding this comment

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

I think we're still not supporting importing p5 in the body 😭. We implemented a fix to support it but then we rolled it back because it caused a major issue with the editor console.

issue: #2327
reverted fix: #2426
bug caused by fix: #2518
reversion: #2547

Copy link
Contributor

Choose a reason for hiding this comment

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

got it, I think this is good to go then!

}

const previewScripts = sketchDoc.createElement('script');
Expand Down