diff --git a/package-lock.json b/package-lock.json index 13e4015b..50484e77 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25001,7 +25001,7 @@ "requires": { "debuglog": "^1.0.1", "dezalgo": "^1.0.0", - "graceful-fs": "4.2.2", + "graceful-fs": "^4.1.2", "once": "^1.3.0" } }, diff --git a/src/scripts/clipperUI/components/sectionPicker.tsx b/src/scripts/clipperUI/components/sectionPicker.tsx index 43339d23..3e8d770d 100644 --- a/src/scripts/clipperUI/components/sectionPicker.tsx +++ b/src/scripts/clipperUI/components/sectionPicker.tsx @@ -29,6 +29,8 @@ interface SectionPickerProp extends ClipperStateProp { export class SectionPickerClass extends ComponentBase { static dataSource: OneNotePicker.OneNotePickerDataSource; + private popupIsOpen: boolean = false; + private escWasPressed: boolean = false; getInitialState(): SectionPickerState { return { @@ -54,6 +56,20 @@ export class SectionPickerClass extends ComponentBase { + const sectionLocationContainer = document.getElementById(Constants.Ids.sectionLocationContainer); + if (sectionLocationContainer) { + sectionLocationContainer.focus(); + } + }, 0); + } } this.props.onPopupToggle(shouldNowBeOpen); } @@ -248,6 +264,27 @@ export class SectionPickerClass extends ComponentBase { + if (ev.keyCode === Constants.KeyCodes.esc && this.popupIsOpen) { + // Mark that ESC was pressed so we can restore focus after the popup closes + this.escWasPressed = true; + } + if (oldOnKeyDown) { + oldOnKeyDown.call(document, ev); + } + }; + + // Remove listener when this element is unmounted + context.onunload = () => { + document.onkeydown = oldOnKeyDown ? oldOnKeyDown.bind(document) : undefined; + }; + } + } + render() { if (this.dataSourceUninitialized()) { // This logic gets executed on app launch (if already signed in) and whenever the user signs in or out ... @@ -295,7 +332,7 @@ export class SectionPickerClass extends ComponentBase +