Skip to content

Commit 4f75b09

Browse files
Editor focus borders on keyboard navigation (microsoft#10462)
* This makes the focus borders on buttons thicker and more noticeable in the default and high contrast themes. Includes: the menu bar, editor selection, simulator transport, sidebar toggles, download and editor bottom bar buttons. * Updated to use --pxt-focus-color in editor where appropriate
1 parent e50a371 commit 4f75b09

File tree

5 files changed

+70
-7
lines changed

5 files changed

+70
-7
lines changed

react-common/styles/onboarding/TeachingBubble.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@
9898
}
9999
}
100100

101+
.common-button:focus-visible {
102+
outline: 2px solid var(--pxt-tertiary-foreground);
103+
outline-offset: 3px;
104+
}
105+
101106
&.no-steps {
102107
flex-direction: row-reverse;
103108
}

theme/accessibility.less

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,17 @@
2020
}
2121

2222
/* Toggle focus */
23-
#mainmenu .editor-menuitem .ui.item:focus {
24-
background: rgba(0,0,0,0.1) !important;
23+
#mainmenu .editor-menuitem {
24+
.ui.item:focus-visible {
25+
background: transparent;
26+
outline: 3px solid white;
27+
outline-offset: -5px;
28+
filter: none;
29+
}
30+
31+
.ui.item.active:focus-visible {
32+
outline-color: black;
33+
}
2534
}
2635

2736
.ui.item:focus, .ui.button:focus {

theme/common.less

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ pre {
234234
}
235235
}
236236

237+
.editor-sidebar .simtoolbar .ui.button:focus-visible {
238+
outline: @editorFocusBorderSize solid var(--pxt-focus-border);
239+
}
240+
237241
#downloadArea {
238242
margin: unset;
239243

@@ -249,6 +253,13 @@ pre {
249253
}
250254
}
251255

256+
#downloadArea .button:focus-visible,
257+
#editortools .button:focus-visible
258+
{
259+
outline: @editorFocusBorderSize solid var(--pxt-focus-border);
260+
outline-offset: 2px;
261+
}
262+
252263
#editorToolbarArea {
253264
margin: 0;
254265
margin-left: auto;
@@ -275,7 +286,7 @@ pre {
275286
color: var(--pxt-primary-foreground) !important; // override !important in semantic ui
276287
border-radius: inherit;
277288

278-
&:hover, &:focus {
289+
&:hover {
279290
background: var(--pxt-primary-background-hover) !important;
280291
color: var(--pxt-primary-foreground-hover) !important;
281292
}
@@ -373,7 +384,7 @@ div.simframe > iframe {
373384
.menubar .ui.menu.fixed .ui.item.editor-menuitem .item.link:hover {
374385
background: none;
375386
}
376-
.menubar .ui.menu.fixed .ui.item.editor-menuitem .item:not(.active) {
387+
.menubar .ui.menu.fixed .ui.item.editor-menuitem .item:not(.active) * {
377388
opacity: 0.8;
378389
}
379390
.menubar .ui.menu.inverted.fixed .ui.item.editor-menuitem .active.item {
@@ -462,6 +473,15 @@ div.simframe > iframe {
462473
border-top-right-radius: 0!important;
463474
border-bottom-right-radius: 0!important;
464475
}
476+
477+
.base-menuitem:focus-visible {
478+
outline: 3px solid white;
479+
outline-offset: -5px;
480+
}
481+
482+
.base-menuitem.active:focus-visible {
483+
outline-color: var(--pxt-target-stencil1);
484+
}
465485
}
466486

467487
#editordropdown {
@@ -693,6 +713,10 @@ div.simframe > iframe {
693713
&:focus {
694714
opacity: 1;
695715
}
716+
717+
&:focus-visible {
718+
outline: @editorFocusBorderSize solid var(--pxt-focus-border);
719+
}
696720
}
697721
#computertogglesim,
698722
#sidedocstoggle {
@@ -1297,6 +1321,11 @@ Field editors
12971321
}
12981322
}
12991323

1324+
#serialPreview .label:focus {
1325+
outline: 3px solid var(--pxt-focus-border) !important;
1326+
outline-offset: -15px;
1327+
}
1328+
13001329
/*******************************
13011330
Layout Variables
13021331
*******************************/

theme/highcontrast.less

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#monacoEditor .blocklyTreeRow,
5959
#monacoEditor .monacoDraggableBlock {
6060
&:focus, &:hover {
61-
outline: 2px solid @selected !important;
61+
outline: @editorFocusBorderSize solid @selected !important;
6262
}
6363
}
6464

@@ -91,6 +91,16 @@
9191
}
9292
}
9393

94+
#editortoggle .active.item {
95+
transition: none;
96+
&:focus {
97+
box-shadow: inset 0 0 0 6px @HCbackground !important;
98+
}
99+
>.icon {
100+
color: @HCbackground !important;
101+
}
102+
}
103+
94104
@media all and (pointer:coarse) { /* If touch screen */
95105
*[tabindex='0'],
96106
*[tabindex*='d1'],
@@ -102,7 +112,7 @@
102112
#monacoEditor .blocklyTreeRow,
103113
#monacoEditor .monacoDraggableBlock {
104114
&:focus, &:hover {
105-
outline: 1px solid transparent !important;
115+
outline: @editorFocusBorderSize solid transparent !important;
106116
}
107117
}
108118
}
@@ -356,7 +366,7 @@
356366

357367
&:focus, &:hover {
358368
color: @HCtextColor !important;
359-
border-color: @selected !important;
369+
outline: @editorFocusBorderSize solid @selected;
360370
background: @HCbackground !important;
361371

362372
i, span {
@@ -646,6 +656,10 @@
646656
&:hover {
647657
border-color: darken(@HCtextColor, 10.0) !important;
648658
}
659+
&:focus {
660+
outline: 3px solid @selected !important;
661+
outline-offset: -15px;
662+
}
649663
}
650664

651665
.ui.button.labeled.icon.editorBack {

theme/themes/pxt/globals/site.variables

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@
217217
/* Detail view */
218218
@homeSelectedCardBorderSize: @homeCardBorderSize*2;
219219
@homeHeaderBorderSize: 3px;
220+
221+
/*-------------------
222+
Editor
223+
--------------------*/
224+
@editorFocusBorderSize: 4px;
225+
220226
/*-------------------
221227
Tutorial
222228
--------------------*/

0 commit comments

Comments
 (0)