Skip to content

Commit 9f0dcc8

Browse files
committed
(kb) highlight focused elements only out of grist doc views
since most kb-related things in grist views are handled manually with specific js, we dont want a default focus ring on stuff that might get focus inside them. before that, a focus ring was added on celleditor_text_editor for example.
1 parent 3d5fd4a commit 9f0dcc8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/client/components/KeyboardFocusHighlighter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class KeyboardFocusHighlighter extends Disposable {
3333
}
3434

3535
const cssKeyboardUser = styled('div', `
36-
& :is(a, input, textarea, select, button, [tabindex="0"]):focus-visible {
36+
& .kb-focus-highlighter-group :is(a, input, textarea, select, button, [tabindex="0"]):focus-visible {
3737
/* simulate default browser focus ring */
3838
outline: 2px solid Highlight !important;
3939
outline: 2px solid -webkit-focus-ring-color !important;

app/client/components/RegionFocusSwitcher.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ export class RegionFocusSwitcher extends Disposable {
113113
dom.attr('role', 'region'),
114114
dom.attr('aria-label', ariaLabel),
115115
dom.attr(ATTRS.regionId, id),
116+
dom.cls('kb-focus-highlighter-group', use => {
117+
// highlight focused elements everywhere except in the grist doc views
118+
if (id !== 'main') {
119+
return true;
120+
}
121+
const gristDoc = this._gristDocObs ? use(this._gristDocObs) : null;
122+
if (!gristDoc) {
123+
return true;
124+
}
125+
if (gristDoc) {
126+
use(gristDoc.activeViewId);
127+
}
128+
return isSpecialPage(gristDoc);
129+
}),
116130
dom.cls('clipboard_group_focus', use => {
117131
const gristDoc = this._gristDocObs ? use(this._gristDocObs) : null;
118132
// if we are not on a grist doc, whole page is always focusable

0 commit comments

Comments
 (0)