@@ -6,27 +6,54 @@ window.onload = function() {
66 var helpTopics = document . getElementById ( 'matching-topics' ) ;
77 /* Keyword search <input> */
88 var searchBox = document . getElementById ( 'topic-search-box' ) ;
9+
10+ /* When TOC gets the focus, setting the focus to helpTopics or searchBox */
11+ window . addEventListener ( 'focus' , function ( ) {
12+ var helpTopics = document . getElementById ( 'matching-topics' ) ;
13+ var searchBox = document . getElementById ( 'topic-search-box' ) ;
14+ var searchResults = document . getElementById ( 'search-results' ) ;
15+
16+ if ( searchResults && searchResults . style . display !== 'none' ) {
17+ helpTopics . focus ( ) ;
18+ } else {
19+ searchBox . focus ( ) ;
20+ }
21+ } ) ;
22+
923 /* Shows the page mapped to the active <select> item */
1024 var clickToView = function ( evnt ) {
1125 evnt . preventDefault ( ) ; // Cancel any submit action
1226 try {
1327 if ( ! Boolean ( helpTopics . value ) ) // Nothing selected
1428 return ;
1529
16- var searchParam = helpTopics [ helpTopics . selectedIndex ] . dataset . contains
17- var targetURI = helpTopics . value + encodeURI ( '?contains=' + searchParam )
18- parent . frames [ 'content' ] . location . replace ( targetURI )
30+ var searchParam = helpTopics [ helpTopics . selectedIndex ] . dataset . contains ;
31+ var targetURI = helpTopics . value + encodeURI ( '?contains=' + searchParam ) ;
32+ parent . frames [ 'content' ] . location . replace ( targetURI ) ;
33+
34+ setTimeout ( function ( ) {
35+ helpTopics . focus ( ) ;
36+ } , 100 ) ;
1937 } catch ( e ) {
2038 /* Handle the DOMException that may be thrown by trying to access cross-origin frames on the `file://` protocol
2139 * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Property_access_denied
2240 */
2341 if ( e instanceof DOMException ) {
24- /* Open the requested doc in a "modal" window */
25- window . open ( targetURI , '_bank' , 'noopener' )
42+ /* Open the requested doc in a "modal" window */
43+ window . open ( targetURI , '_bank' , 'noopener' ) ;
44+
45+ setTimeout ( function ( ) {
46+ window . focus ( ) ;
47+ helpTopics . focus ( ) ;
48+ } , 100 ) ;
2649 } else {
27- var docIndex = helpTopics . selectedIndex
28- var requestedDoc = ( docIndex >= 0 ) ? helpTopics [ docIndex ] . innerHTML : helpTopics . value ;
29- window . alert ( '"' + requestedDoc + '" is missing or access is restricted.' )
50+ var docIndex = helpTopics . selectedIndex ;
51+ var requestedDoc = ( docIndex >= 0 ) ? helpTopics [ docIndex ] . innerHTML : helpTopics . value ;
52+ window . alert ( '"' + requestedDoc + '" is missing or access is restricted.' ) ;
53+
54+ setTimeout ( function ( ) {
55+ helpTopics . focus ( ) ;
56+ } , 100 ) ;
3057 }
3158 }
3259 } ;
@@ -88,11 +115,23 @@ window.onload = function() {
88115 /* Min visible size is 2 b/c the <optgroup> label is counted */
89116 helpTopics . size = Math . max ( foundTopics . length + 1 , 2 ) ;
90117 /* Make sure mobile <select> boxes are never blank */
91- helpTopics . selectedIndex = 0 ;
118+ // helpTopics.selectedIndex = 0;
92119 helpTopics . addEventListener ( 'change' , clickToView , { 'passive' : false } ) ;
93120 helpTopics . addEventListener ( 'focus' ,
94121 /* Selecting the first <option> should *also* fire a 'change' event */
95122 function ( ) { if ( this . selectedIndex === 0 ) this . selectedIndex -- } , { 'once' : true } ) ;
123+
124+ var focusContent = function ( evnt ) {
125+ if ( evnt . type === 'dblclick' || evnt . key === 'Enter' || evnt . keyCode === 13 ) {
126+ setTimeout ( function ( ) {
127+ if ( parent . frames [ 'content' ] ) {
128+ parent . frames [ 'content' ] . focus ( ) ;
129+ }
130+ } , 100 ) ;
131+ }
132+ } ;
133+ helpTopics . addEventListener ( 'keydown' , focusContent ) ;
134+ helpTopics . addEventListener ( 'dblclick' , focusContent ) ;
96135 }
97136 } catch ( e ) {
98137 console . error ( e . message )
0 commit comments