Skip to content

Commit 7bc146d

Browse files
committed
(kb) make sure panel content is not focusable until we want to
before, panel content was always focusable. This made some unintended behavior, like clicking a "a" element would keep the focus, and make the `input` command stop working. now if we just click a "a" element inside a non-focused panel, it wont grab focus.
1 parent 6c2a43a commit 7bc146d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app/client/components/RegionFocusSwitcher.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,20 @@ export class RegionFocusSwitcher extends Disposable {
105105
dom.attr('aria-label', ariaLabel),
106106
dom.attr(ATTRS.regionId, id),
107107
dom.cls('clipboard_group_focus', use => {
108-
// top/left/right panels are always focusable
109-
if (id !== 'main') {
110-
return true;
111-
}
112108
const gristDoc = this._gristDocObs ? use(this._gristDocObs) : null;
113-
// if we are not on a grist doc, main panel is always focusable
109+
// if we are not on a grist doc, whole page is always focusable
114110
if (!gristDoc) {
115111
return true;
116112
}
113+
const current = use(this.current);
114+
// on a grist doc, panel content is focusable only if it's the current region
115+
if (current?.type === 'panel' && current.id === id) {
116+
return true;
117+
}
117118
if (gristDoc) {
118119
use(gristDoc.activeViewId);
119120
}
120-
// if we are on a grist doc, main panel is focusable only if we are not the actual document view
121+
// on a grist doc, main panel is focusable only if we are not the actual document view
121122
return isSpecialPage(gristDoc);
122123
}),
123124
dom.cls('clipboard_forbid_focus', use => {

0 commit comments

Comments
 (0)