Skip to content

Commit 885df74

Browse files
authored
chore(site): update Text.js to 1.6.1 and drop the DevTools focus workaround (#62353)
1 parent 72da577 commit 885df74

3 files changed

Lines changed: 15 additions & 25 deletions

File tree

‎bun.lock‎

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎services/site/package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
"@solidjs/meta": "catalog:",
2828
"@solidjs/router": "catalog:",
2929
"@solidjs/start": "catalog:",
30-
"@textjs/app": "1.6.0",
31-
"@textjs/core": "1.6.0",
32-
"@textjs/opencode": "1.6.0",
33-
"@textjs/react": "1.6.0",
30+
"@textjs/app": "1.6.1",
31+
"@textjs/core": "1.6.1",
32+
"@textjs/opencode": "1.6.1",
33+
"@textjs/react": "1.6.1",
3434
"fuzzysort": "3.1.0",
3535
"nitro": "3.0.260903-beta",
3636
"number-flow": "0.6.2",

‎services/site/textjs/src/lite.tsx‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,14 @@ declare const __TEXTJS_YOGA__: string
1616

1717
export async function start(options: { away?: () => boolean; onExit?: () => void } = {}) {
1818
await initYoga({ wasm: new URL(__TEXTJS_YOGA__, import.meta.url) })
19-
// Text.js 1.6 counts a press as the click back from DevTools only within 300 ms of the window's
20-
// focus event, so it misses a visitor who came back while Lite loaded: their clicks on the page,
21-
// which already has focus, never reached Lite. Replay that focus for their next press, until
22-
// Text.js ships createHostInput({ away }), which does this itself. Registered first, so it runs
23-
// before createHostInput's own listener.
24-
const replay = (e: MouseEvent) => {
25-
if (e.button !== 0 || e.ctrlKey) return
26-
document.removeEventListener("mousedown", replay, true)
27-
window.dispatchEvent(new FocusEvent("focus"))
28-
}
29-
if (options.away?.() && document.hasFocus()) document.addEventListener("mousedown", replay, true)
3019
// Keys reach the app only once the visitor clicks the page to come back from DevTools, and never
3120
// while they type in one of its fields, so the site's own shortcuts keep working until then.
32-
const input = createHostInput()
21+
// `away` covers the visitor who came back while Lite downloaded: they left the page before it
22+
// started listening, so its next press is the click back from DevTools.
23+
const input = createHostInput({ away: options.away?.() })
3324
const stop = () => {
3425
root.unmount()
3526
input.dispose()
36-
document.removeEventListener("mousedown", replay, true)
3727
}
3828
const exit = () => {
3929
stop()

0 commit comments

Comments
 (0)