Skip to content

Commit aef60c4

Browse files
Use 'ESC' to close keyboard help docs when focused (#45)
This does not work for reference docs due to the keydown event happening in an iframe
1 parent bef6521 commit aef60c4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

webapp/src/container.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,12 @@ export class SideDocs extends data.Component<SideDocsProps, SideDocsState> {
697697
|| this.state.docsUrl != nextState.docsUrl;
698698
}
699699

700+
protected handleOnKeyDown = (ev: React.KeyboardEvent<HTMLElement>) => {
701+
if (ev.key == "Escape") {
702+
this.collapse();
703+
}
704+
}
705+
700706
renderCore() {
701707
const { sideDocsCollapsed, docsUrl } = this.state;
702708
const isRTL = pxt.Util.isUserLanguageRtl();
@@ -713,7 +719,7 @@ export class SideDocs extends data.Component<SideDocsProps, SideDocsState> {
713719
<button id="sidedocstoggle" role="button" aria-label={sideDocsCollapsed ? lf("Expand the side documentation") : lf("Collapse the side documentation")} className="ui icon button large" onClick={this.toggleVisibility}>
714720
<sui.Icon icon={`icon inverted chevron ${showLeftChevron ? 'left' : 'right'}`} />
715721
</button>
716-
<div id="sidedocs">
722+
<div id="sidedocs" onKeyDown={this.handleOnKeyDown}>
717723
<div id="sidedocsframe-wrapper">
718724
{this.renderContent(url, isBuiltIn, lockedEditor)}
719725
</div>

0 commit comments

Comments
 (0)