From 211569f7f5c4023f3ef5f4a3b52b6e495d025ff6 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:41:57 -0300 Subject: [PATCH] AlwaysExpandRoles: Fix collapse roles button not appearing --- src/plugins/alwaysExpandRoles/index.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/plugins/alwaysExpandRoles/index.ts b/src/plugins/alwaysExpandRoles/index.ts index 1c20b977..c674f90c 100644 --- a/src/plugins/alwaysExpandRoles/index.ts +++ b/src/plugins/alwaysExpandRoles/index.ts @@ -28,10 +28,18 @@ export default definePlugin({ patches: [ { find: 'action:"EXPAND_ROLES"', - replacement: { - match: /(roles:\i(?=.+?(\i)\(!0\)[,;]\i\({action:"EXPAND_ROLES"}\)).+?\[\i,\2\]=\i\.useState\()!1\)/, - replace: (_, rest, setExpandedRoles) => `${rest}!0)` - } + replacement: [ + { + match: /(roles:\i(?=.+?(\i)\(!0\)[,;]\i\({action:"EXPAND_ROLES"}\)).+?\[\i,\2\]=\i\.useState\()!1\)/, + replace: (_, rest, setExpandedRoles) => `${rest}!0)` + }, + { + // Fix not calculating non-expanded roles because the above patch makes the default "expanded", + // which makes the collapse button never show up and calculation never occur + match: /(?<=useLayoutEffect\(\(\)=>{if\()\i/, + replace: isExpanded => "false" + } + ] } ] });