From f766ea6b4959d5a0bc4515fac5d3613d5bf35d48 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 11 Mar 2026 03:41:28 +0100 Subject: [PATCH] TextReplace: fix rule section closing when changing find --- src/plugins/textReplace/index.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/textReplace/index.tsx b/src/plugins/textReplace/index.tsx index 8e70d85c8..81cea86e0 100644 --- a/src/plugins/textReplace/index.tsx +++ b/src/plugins/textReplace/index.tsx @@ -34,7 +34,7 @@ import { React, TextInput, useState } from "@webpack/common"; const cl = classNameFactory("vc-textReplace-"); -type Rule = Record<"find" | "replace" | "onlyIfIncludes", string>; +type Rule = Record<"find" | "replace" | "onlyIfIncludes" | "id", string>; interface TextReplaceProps { title: string; @@ -46,7 +46,8 @@ interface TextReplaceProps { const makeEmptyRule: () => Rule = () => ({ find: "", replace: "", - onlyIfIncludes: "" + onlyIfIncludes: "", + id: crypto.randomUUID() }); const makeEmptyRuleArray = () => [makeEmptyRule()]; @@ -123,7 +124,7 @@ function Input({ initialValue, onChange, placeholder }: { value={value} onChange={setValue} spellCheck={false} - onBlur={() => value !== initialValue && onChange(value)} + onBlur={() => value !== initialValue && setTimeout(() => onChange(value), 0)} /> ); } @@ -168,7 +169,7 @@ function TextReplace({ title, description, rulesArray, isRegex = false }: TextRe {rulesArray.map((rule, index) => ( <>
@@ -272,6 +273,11 @@ export default definePlugin({ settings, + start() { + settings.store.regexRules.forEach(rule => rule.id ??= crypto.randomUUID()); + settings.store.stringRules.forEach(rule => rule.id ??= crypto.randomUUID()); + }, + onBeforeMessageSend(channelId, msg) { // Channel used for sharing rules, applying rules here would be messy if (channelId === TEXT_REPLACE_RULES_CHANNEL_ID) return;