summaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
authorAAGaming <aa@mail.catvibers.me>2022-10-01 21:22:30 -0400
committerAAGaming <aa@mail.catvibers.me>2022-10-01 21:22:30 -0400
commit3c00eb8cf4f5b02b8ec87fc1d9ccdd70221dd916 (patch)
treea0fc935492db619394415bbcccef3cc724ae901f /frontend/src
parent21e1d8504a184d9f9384b7ceab2d4b3cf94c1e36 (diff)
downloaddecky-loader-3c00eb8cf4f5b02b8ec87fc1d9ccdd70221dd916.tar.gz
decky-loader-3c00eb8cf4f5b02b8ec87fc1d9ccdd70221dd916.zip
fix friends menu focusing itself
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/components/PluginView.tsx2
-rw-r--r--frontend/src/tabs-hook.ts1
-rw-r--r--frontend/src/toaster.tsx32
3 files changed, 33 insertions, 2 deletions
diff --git a/frontend/src/components/PluginView.tsx b/frontend/src/components/PluginView.tsx
index c56d731f..0d0a52cf 100644
--- a/frontend/src/components/PluginView.tsx
+++ b/frontend/src/components/PluginView.tsx
@@ -32,7 +32,7 @@ const PluginView: VFC = () => {
.map(({ name, icon }) => (
<PanelSectionRow key={name}>
<ButtonItem layout="below" onClick={() => setActivePlugin(name)}>
- <div style={{ display: 'flex', alignItems: "center", justifyContent: 'space-between' }}>
+ <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
{icon}
<div>{name}</div>
<NotificationBadge show={updates?.has(name)} style={{ top: '-5px', right: '-5px' }} />
diff --git a/frontend/src/tabs-hook.ts b/frontend/src/tabs-hook.ts
index be413de0..65e1b2b4 100644
--- a/frontend/src/tabs-hook.ts
+++ b/frontend/src/tabs-hook.ts
@@ -101,6 +101,7 @@ class TabsHook extends Logger {
});
this.cNode = scrollRoot;
this.cNode.stateNode.forceUpdate();
+ this.log('Finished initial injection');
})();
}
diff --git a/frontend/src/toaster.tsx b/frontend/src/toaster.tsx
index fcf89abb..d03163eb 100644
--- a/frontend/src/toaster.tsx
+++ b/frontend/src/toaster.tsx
@@ -1,4 +1,14 @@
-import { Patch, ToastData, afterPatch, findInReactTree, findModuleChild, sleep } from 'decky-frontend-lib';
+import {
+ Patch,
+ ToastData,
+ afterPatch,
+ callOriginal,
+ findInReactTree,
+ findModuleChild,
+ replacePatch,
+ sleep,
+ staticClasses,
+} from 'decky-frontend-lib';
import { ReactNode } from 'react';
import Toast from './components/Toast';
@@ -27,6 +37,25 @@ class Toaster extends Logger {
async init() {
let instance: any;
+ const focusManager = findModuleChild((m) => {
+ if (typeof m !== 'object') return false;
+ for (let prop in m) {
+ if (m[prop]?.prototype?.TakeFocus) return m[prop];
+ }
+ return false;
+ });
+
+ const focusWorkaroundPatch = replacePatch(focusManager.prototype, 'BFocusWithin', function () {
+ // @ts-ignore
+ console.log(this as any);
+ // @ts-ignore
+ if (this.m_node?.m_element && this.m_node?.m_element.classList.contains(staticClasses.TabGroupPanel)) {
+ console.log('got the focus hook');
+ return true;
+ }
+
+ return callOriginal;
+ });
while (true) {
instance = findInReactTree(
(document.getElementById('root') as any)._reactRootContainer._internalRoot.current,
@@ -71,6 +100,7 @@ class Toaster extends Logger {
if (typeof m[prop]?.settings && m[prop]?.communityPreferences) return m[prop];
}
});
+ focusWorkaroundPatch.unpatch();
this.log('Initialized');
this.ready = true;
}