Spaces:
Running
Running
Use hotkey for node search in tests.
Browse files
lynxkite-app/web/src/workspace/Workspace.tsx
CHANGED
@@ -180,6 +180,39 @@ function LynxKiteFlow() {
|
|
180 |
}),
|
181 |
[],
|
182 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
const closeNodeSearch = useCallback(() => {
|
184 |
setNodeSearchSettings(undefined);
|
185 |
setSuppressSearchUntil(Date.now() + 200);
|
|
|
180 |
}),
|
181 |
[],
|
182 |
);
|
183 |
+
|
184 |
+
// Global keyboard shortcuts.
|
185 |
+
useEffect(() => {
|
186 |
+
const handleKeyDown = (event: KeyboardEvent) => {
|
187 |
+
// Show the node search dialog on "/".
|
188 |
+
if (
|
189 |
+
event.key === "/" &&
|
190 |
+
!nodeSearchSettings &&
|
191 |
+
!isTypingInFormElement()
|
192 |
+
) {
|
193 |
+
event.preventDefault();
|
194 |
+
setNodeSearchSettings({
|
195 |
+
pos: { x: 100, y: 100 },
|
196 |
+
boxes: catalog.data![state.workspace.env!],
|
197 |
+
});
|
198 |
+
}
|
199 |
+
};
|
200 |
+
document.addEventListener("keydown", handleKeyDown);
|
201 |
+
return () => {
|
202 |
+
document.removeEventListener("keydown", handleKeyDown);
|
203 |
+
};
|
204 |
+
}, [catalog.data, nodeSearchSettings, state.workspace.env]);
|
205 |
+
|
206 |
+
function isTypingInFormElement() {
|
207 |
+
const activeElement = document.activeElement;
|
208 |
+
return (
|
209 |
+
activeElement &&
|
210 |
+
(activeElement.tagName === "INPUT" ||
|
211 |
+
activeElement.tagName === "TEXTAREA" ||
|
212 |
+
(activeElement as HTMLElement).isContentEditable)
|
213 |
+
);
|
214 |
+
}
|
215 |
+
|
216 |
const closeNodeSearch = useCallback(() => {
|
217 |
setNodeSearchSettings(undefined);
|
218 |
setSuppressSearchUntil(Date.now() + 200);
|
lynxkite-app/web/tests/lynxkite.ts
CHANGED
@@ -63,9 +63,8 @@ export class Workspace {
|
|
63 |
}
|
64 |
|
65 |
// Some x,y offset, otherwise the box handle may fall outside the viewport.
|
66 |
-
await this.page
|
67 |
-
|
68 |
-
.click({ position: { x: 20, y: 20 } });
|
69 |
await this.page.locator(".node-search").getByText(boxName).click();
|
70 |
await this.page.keyboard.press("Escape");
|
71 |
// Workaround to wait for the deselection animation after choosing a box. Otherwise, the next box will not be added.
|
|
|
63 |
}
|
64 |
|
65 |
// Some x,y offset, otherwise the box handle may fall outside the viewport.
|
66 |
+
await this.page.locator(".ws-name").click();
|
67 |
+
await this.page.keyboard.press("/");
|
|
|
68 |
await this.page.locator(".node-search").getByText(boxName).click();
|
69 |
await this.page.keyboard.press("Escape");
|
70 |
// Workaround to wait for the deselection animation after choosing a box. Otherwise, the next box will not be added.
|