Skip to content

Commit ed38733

Browse files
committed
Simplify code comments for readability
1 parent 6796c44 commit ed38733

3 files changed

Lines changed: 4 additions & 23 deletions

File tree

src/scripts/clipperUI/components/sectionPicker.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ export class SectionPickerClass extends ComponentBase<SectionPickerState, Sectio
6767
}
6868
this.props.onPopupToggle(shouldNowBeOpen);
6969
if (shouldNowBeOpen) {
70-
// After the popup renders, move keyboard focus to the currently selected section item
71-
// so that keyboard users can identify which item is selected and navigate from there.
72-
// Also attach an arrow key handler so keyboard users can navigate the list with Up/Down.
70+
// Focus the selected section and attach arrow key navigation for keyboard users
7371
setTimeout(() => {
7472
let sectionPickerPopup = document.getElementById("sectionPickerContainer");
7573

@@ -86,21 +84,14 @@ export class SectionPickerClass extends ComponentBase<SectionPickerState, Sectio
8684
elementToFocus.focus();
8785
}
8886

89-
// Attach Up/Down arrow key navigation for the popup list.
90-
// The OneNotePicker library only handles Enter/Tab, so we add arrow key support here.
91-
// The listener is attached to the popup element which is removed from the DOM when the
92-
// popup closes, so there is no need to explicitly clean it up.
93-
// Guard against attaching multiple listeners if onPopupToggle(true) is called more than once.
94-
// Use capture so the popup still receives Up/Down events before child controls suppress bubbling.
87+
// Attach Up/Down arrow key navigation (OneNotePicker only handles Enter/Tab)
9588
if (sectionPickerPopup && !sectionPickerPopup.getAttribute("data-arrow-key-handler-attached")) {
9689
sectionPickerPopup.setAttribute("data-arrow-key-handler-attached", "true");
9790
sectionPickerPopup.addEventListener("keydown", (e: KeyboardEvent) => {
9891
if (e.which !== Constants.KeyCodes.up && e.which !== Constants.KeyCodes.down) {
9992
return;
10093
}
10194
e.preventDefault();
102-
// Only include visible items — exclude elements whose parent is inside a "Closed"
103-
// collapsed notebook or sectionGroup (children remain in the DOM but are hidden via CSS).
10495
let focusableItems = Array.prototype.slice.call(
10596
sectionPickerPopup.querySelectorAll("[tabindex]:not([tabindex=\"-1\"])")
10697
).filter((el) => {
@@ -302,7 +293,6 @@ export class SectionPickerClass extends ComponentBase<SectionPickerState, Sectio
302293
}
303294

304295
// Attach escape key handler to return focus to the dropdown button when Escape is pressed
305-
// This is needed because the OneNotePicker component handles Escape internally without calling onPopupToggle
306296
attachEscapeFocusHandler(element: HTMLElement, isInitialized: boolean) {
307297
if (!isInitialized) {
308298
const escKeyCode = 27;

src/scripts/clipperUI/mainController.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ export class MainControllerClass extends ComponentBase<MainControllerState, Main
101101
}
102102
}
103103

104-
/**
105-
* Handles focus trapping within certain panels to prevent keyboard focus from escaping
106-
* when navigating with Tab key. This ensures accessibility compliance by keeping focus
107-
* within the popup until the user explicitly closes it.
108-
*/
104+
// Prevents Tab key from moving focus outside the popup
109105
handleFocusTrap(event: KeyboardEvent) {
110106
// Only trap focus for specific panels that need it
111107
if (this.state.currentPanel !== PanelType.ClippingSuccess &&

src/scripts/extensions/clipperInject.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,7 @@ export class ClipperInject extends FrameInjectBase<ClipperInjectOptions> {
8484
this.updateUiSizeAttributes();
8585
this.overrideTransformStyles(document.documentElement);
8686

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

0 commit comments

Comments
 (0)