Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/src/routes/devices.$id.settings.keyboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function SettingsKeyboardRoute() {
if ("error" in resp) return;
setKeyboardLayout(resp.result as string);
});
}, []); // eslint-disable-line react-hooks/exhaustive-deps
}, [send, setKeyboardLayout]);
Copy link
Contributor Author

@IDisposable IDisposable May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change at minimum needs to be landed somehow. As it stand without those dependencies listed we're going send("getKeyboardLayout" message and call the get setKeyboardLayout(` every single render cycle.
☝️ @adamshiervani

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ym, this really needs to be merged... tons of React rerenders until we do...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty dependencies mean that it will behave like componentDidMount, running only once when the component mounts. I can also confirm that it does not re-render outside the case mentioned above.


const onKeyboardLayoutChange = useCallback(
(e: React.ChangeEvent<HTMLSelectElement>) => {
Expand Down
3 changes: 1 addition & 2 deletions ui/src/routes/devices.$id.settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export default function SettingsRoute() {
className={({ isActive }) => (isActive ? "active" : "")}
>
<div className="flex items-center gap-x-2 rounded-md px-2.5 py-2.5 text-sm transition-colors hover:bg-slate-100 dark:hover:bg-slate-700 in-[.active]:bg-blue-50 in-[.active]:text-blue-700! md:in-[.active]:bg-transparent dark:in-[.active]:bg-blue-900 dark:in-[.active]:text-blue-200! dark:md:in-[.active]:bg-transparent">

<LuMouse className="h-4 w-4 shrink-0" />
<h1>Mouse</h1>
</div>
Expand All @@ -163,7 +162,7 @@ export default function SettingsRoute() {
to="keyboard"
className={({ isActive }) => (isActive ? "active" : "")}
>
<div className="flex items-center gap-x-2 rounded-md px-2.5 py-2.5 text-sm transition-colors hover:bg-slate-100 dark:hover:bg-slate-700 [.active_&]:bg-blue-50 [.active_&]:!text-blue-700 md:[.active_&]:bg-transparent dark:[.active_&]:bg-blue-900 dark:[.active_&]:!text-blue-200 dark:md:[.active_&]:bg-transparent">
<div className="flex items-center gap-x-2 rounded-md px-2.5 py-2.5 text-sm transition-colors hover:bg-slate-100 dark:hover:bg-slate-700 in-[.active]:bg-blue-50 in-[.active]:text-blue-700! md:in-[.active]:bg-transparent dark:in-[.active]:bg-blue-900 dark:in-[.active]:text-blue-200! dark:md:in-[.active]:bg-transparent">
<LuKeyboard className="h-4 w-4 shrink-0" />
<h1>Keyboard</h1>
</div>
Expand Down