Skip to content

Commit 2f0a523

Browse files
committed
fix: key tips not updating and not hiding
closes #7412
1 parent ba82756 commit 2f0a523

File tree

3 files changed

+46
-37
lines changed

3 files changed

+46
-37
lines changed

frontend/src/ts/components/layout/footer/Footer.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,14 @@ import { getFocus } from "../../../signals/core";
44
import { showModal } from "../../../stores/modals";
55
import { Button } from "../../common/Button";
66

7+
import { Keytips } from "./Keytips";
78
import { ThemeIndicator } from "./ThemeIndicator";
89
import { VersionButton } from "./VersionButton";
910

1011
export function Footer(): JSXElement {
1112
return (
1213
<footer class="text-sub relative text-xs">
13-
<div
14-
class="mb-8 text-center leading-loose transition-opacity"
15-
classList={{
16-
"opacity-0": getFocus(),
17-
}}
18-
>
19-
<kbd>tab</kbd> and <kbd>enter</kbd> - restart test
20-
<br />
21-
<kbd>ctrl/cmd</kbd> + <kbd>shift</kbd> + <kbd>p</kbd> or <kbd>esc</kbd>{" "}
22-
- command line
23-
</div>
14+
<Keytips />
2415

2516
<div
2617
class="-m-2 flex justify-between gap-8 transition-opacity"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { JSXElement, Show } from "solid-js";
2+
3+
import { getConfig } from "../../../signals/config";
4+
import { getFocus } from "../../../signals/core";
5+
import { Conditional } from "../../common/Conditional";
6+
7+
export function Keytips(): JSXElement {
8+
const userAgent = window.navigator.userAgent.toLowerCase();
9+
const modifierKey =
10+
userAgent.includes("mac") && !userAgent.includes("firefox")
11+
? "cmd"
12+
: "ctrl";
13+
14+
const commandKey = (): string =>
15+
getConfig.quickRestart === "esc" ? "tab" : "esc";
16+
17+
return (
18+
<Show when={getConfig.showKeyTips}>
19+
<div
20+
class="mb-8 text-center leading-loose transition-opacity"
21+
classList={{
22+
"opacity-0": getFocus(),
23+
}}
24+
>
25+
<Conditional
26+
if={getConfig.quickRestart === "off"}
27+
then={
28+
<>
29+
<kbd>tab</kbd> + <kbd>enter</kbd> - restart test
30+
</>
31+
}
32+
else={
33+
<>
34+
<kbd>{getConfig.quickRestart}</kbd> - restart test
35+
</>
36+
}
37+
/>
38+
<br />
39+
<kbd>{commandKey()}</kbd> or <kbd>{modifierKey}</kbd> + <kbd>shift</kbd>{" "}
40+
+ <kbd>p</kbd> - command line
41+
</div>
42+
</Show>
43+
);
44+
}

frontend/src/ts/ui.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,6 @@ export function setMediaQueryDebugLevel(level: number): void {
4343
}
4444
}
4545

46-
function updateKeytips(): void {
47-
const userAgent = window.navigator.userAgent.toLowerCase();
48-
const modifierKey =
49-
userAgent.includes("mac") && !userAgent.includes("firefox")
50-
? "cmd"
51-
: "ctrl";
52-
53-
const commandKey = Config.quickRestart === "esc" ? "tab" : "esc";
54-
qs("footer .keyTips")?.setHtml(`
55-
${
56-
Config.quickRestart === "off"
57-
? "<kbd>tab</kbd> + <kbd>enter</kbd>"
58-
: `<kbd>${Config.quickRestart}</kbd>`
59-
} - restart test<br>
60-
<kbd>${commandKey}</kbd> or <kbd>${modifierKey}</kbd> + <kbd>shift</kbd> + <kbd>p</kbd> - command line`);
61-
}
62-
6346
if (isDevEnvironment()) {
6447
qs("header #logo .top")?.setText("localhost");
6548
qs("head title")?.setText(
@@ -124,15 +107,6 @@ createEffect(() => {
124107
});
125108

126109
ConfigEvent.subscribe(async ({ key }) => {
127-
if (key === "quickRestart") updateKeytips();
128-
if (key === "showKeyTips") {
129-
const keyTipsElement = qs("footer .keyTips");
130-
if (Config.showKeyTips) {
131-
keyTipsElement?.removeClass("hidden");
132-
} else {
133-
keyTipsElement?.addClass("hidden");
134-
}
135-
}
136110
if (key === "fontFamily") {
137111
await applyFontFamily();
138112
}

0 commit comments

Comments
 (0)