Skip to content

Commit f7a108a

Browse files
committed
0.23.1: Fix keyboard focus-stealing caused by TextInputHandler
1 parent 4777e4b commit f7a108a

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lazy-widgets",
3-
"version": "0.23.0",
3+
"version": "0.23.1",
44
"description": "Typescript retained mode GUI for the HTML canvas API",
55
"main": "dist/index.js",
66
"module": "dist/index.js",

src/drivers/DOMKeyboardDriver.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ export class DOMKeyboardDriver extends KeyboardDriver<DOMKeyboardDriverGroup, DO
116116
}
117117

118118
for (const group of this.groups) {
119+
for (const root of group.enabledRoots) {
120+
const inputHandler = root.currentTextInputHandler;
121+
if (!inputHandler) {
122+
continue;
123+
}
124+
125+
if ((inputHandler.domElems as readonly Element[]).indexOf(newTarget) >= 0) {
126+
// HACK prevent VK from stealing focus of root, preventing
127+
// TextInput widgets from losing focus whenever the VK
128+
// is opened, causing the VK to break
129+
return false;
130+
}
131+
}
132+
119133
// XXX even if the group is not selectable, the focus should still
120134
// not be cleared when a non-selectable group's DOM element is
121135
// focused, since it can be focused by clicking with the mouse

src/drivers/KeyboardDriver.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import type { Root } from '../core/Root.js';
99
import type { CaptureList } from '../core/CaptureList.js';
1010
import { insertValueIntoOrderedSubsetList } from '../index.js';
1111

12-
// TODO should enabledRoots be deprecated/removed? it was only needed for
13-
// tab-focusing, but we have tabbableRoots now and nothing in the core or
14-
// WLE integration libraries is using it
15-
1612
/**
1713
* A group of Roots. When a {@link TabSelectEvent} is not captured by a
1814
* {@link Root} in a group, the TabSelectEvent is carried over to the next (or

0 commit comments

Comments
 (0)