Enter key opens version page (#287)

Co-authored-by: Makhmudjon Inadullaev <makhmudjon@MakhmudjonsMBP2.home>

Makhmudjon Inadullaev committed Oct 27, 2022 at 16:24 UTC c810906ae748a9ec06069c907df9f282f362bd59
2 files changed +7 -1
src/theme/nav.yml
+1
@@ -1050,6 +1050,7 @@
1050 - title: Version 9.0.1 (Current Release)
1051 shortName: v9
1052 url: /cli/v9
1053 + tabIndex: 4
1054 default: false
1055 children:
1056 - title: CLI Commands
theme/src/components/variant-select.js
+6 -1
@@ -42,8 +42,13 @@ function VariantSelect(props) {
42 if (match.page.url === path) {
43 selectedItem = match;
44 }
45 + function onItemEnterKey(event) {
46 + if (event.key === 'Enter') {
47 + window.location.href = match.page.url;
48 + }
49 + }
50
46 - items.push(<Dropdown.Item onBlur={index === (variantPages.length - 1) ? collapseDropdown : undefined} tabIndex={match.variant.tabIndex} onClick={() => { window.location.href = match.page.url; }} key={match.variant.title}>{match.variant.title}</Dropdown.Item>);
51 + items.push(<Dropdown.Item onKeyDown={onItemEnterKey} onBlur={index === (variantPages.length - 1) ? collapseDropdown : undefined} tabIndex={match.variant.tabIndex} onClick={() => { window.location.href = match.page.url; }} key={match.variant.title}>{match.variant.title}</Dropdown.Item>);
52 });
53
54 return (