Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/scripts/clipperUI/mainController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ export class MainControllerClass extends ComponentBase<MainControllerState, Main
<div
id={Constants.Ids.mainController}
{...this.onElementDraw(this.onMainControllerDraw)}
role="main"
role="dialog"
aria-modal="true"
aria-label={Localization.getLocalizedString("WebClipper.Label.OneNoteWebClipper")} >
{closeButtonToRender}
<div className="panelContent">
Expand Down
19 changes: 19 additions & 0 deletions src/scripts/extensions/clipperInject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ export class ClipperInject extends FrameInjectBase<ClipperInjectOptions> {
this.updateUiSizeAttributes();
this.overrideTransformStyles(document.documentElement);

// The clipper frame is now visible; hide page body from assistive technologies
// so that tools like Voice Access do not number background page controls.
// The frame is appended to <html> (not <body>), so marking <body aria-hidden>
// and inert only hides page content while keeping the clipper iframe accessible.
// aria-hidden removes body from the AT tree; inert also disables pointer events
// so Voice Access cannot enumerate or activate background controls.
if (document.body) {
document.body.setAttribute("aria-hidden", "true");
document.body.setAttribute("inert", "");
}

this.logger = new CommunicatorLoggerPure(this.uiCommunicator);

this.updatePageInfo();
Expand Down Expand Up @@ -316,6 +327,10 @@ export class ClipperInject extends FrameInjectBase<ClipperInjectOptions> {

this.uiCommunicator.registerFunction(Constants.FunctionKeys.hideUi, () => {
this.frame.style.display = "none";
if (document.body) {
document.body.removeAttribute("aria-hidden");
document.body.removeAttribute("inert");
}
});

this.uiCommunicator.registerFunction(Constants.FunctionKeys.refreshPage, () => {
Expand Down Expand Up @@ -375,6 +390,10 @@ export class ClipperInject extends FrameInjectBase<ClipperInjectOptions> {
private toggleClipper() {
if (this.frame.style.display === "none") {
this.frame.style.display = "";
if (document.body) {
document.body.setAttribute("aria-hidden", "true");
document.body.setAttribute("inert", "");
}
}
this.uiCommunicator.callRemoteFunction(Constants.FunctionKeys.toggleClipper);
}
Expand Down
11 changes: 11 additions & 0 deletions src/tests/clipperUI/mainController_tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,17 @@ export class MainControllerTests extends TestModule {
"The close button should render when the clipper is not clipping to OneNote API");
}
});

test("The main controller should have role='dialog' and aria-modal='true' for accessibility", () => {
MithrilUtils.mountToFixture(this.defaultComponent);

let mainController = document.getElementById(Constants.Ids.mainController);
ok(mainController, "The main controller element should exist");
strictEqual(mainController.getAttribute("role"), "dialog",
"The main controller should have role='dialog' to prevent Voice Access from numbering background controls");
strictEqual(mainController.getAttribute("aria-modal"), "true",
"The main controller should have aria-modal='true' to mark it as a modal dialog");
});
}

private getMockRequestError(): OneNoteApi.RequestError {
Expand Down
Loading