Vencord icon indicating copy to clipboard operation
Vencord copied to clipboard

fix: PatchHelper not autofilling match field

Open waresnew opened this issue 1 year ago • 3 comments

Before:

Discord_XzB83B35BL

After:

Discord_cEkrvhtRTp

I made it so modifying initialValue from the parent will cause a re-render anyway, since otherwise, you would only be able to change the textbox's contents through onChange

I think externalValue would be a better name now bc you can change the value after setting it

I'm pretty sure a separate state was originally made for value to let people type in the type box even if there's an error, but you can still do that after my change (so it should be fine)

waresnew avatar Apr 06 '24 22:04 waresnew

I made this exact change when I made the full patch input- it was reverted and I was told this is not the correct solution.

I suggested an alternative solution here, which seems correct.

MrDiamondDog avatar Apr 06 '24 22:04 MrDiamondDog

I suggested an alternative solution here, which seems correct.

(we talked about it on Discord, but basically it has a side effect where you can't type anything if there's an error [prob a TextInput feature], and we both agreed that you prob have to modify CheckedTextInput to fix this bug)

@MrDiamondDog told me that ven said that this change causes onChange to fire without the user typing anything

I think it's bc useEffect hooks run when you first render them (eg. when opening up settings page)

So I just made it so you don't fire onchange if it was bc of an external change (I tested it and no non-user-input onChange events were fired)

Hopefully it's good now

waresnew avatar Apr 06 '24 22:04 waresnew

Using an effect should really be unnecessary here and the actual problem needs to be found rather than using a bandaid solution

lewisakura avatar Apr 16 '24 08:04 lewisakura

now that f74da73 has been added, i'm pretty sure this can be fixed by using the same code that the new regex find uses for the match field as well

@Nuckyz do you wanna add that or should i?

waresnew avatar May 18 '24 15:05 waresnew

now that f74da73 has been added, i'm pretty sure this can be fixed by using the same code that the new regex find uses for the match field as well

@Nuckyz do you wanna add that or should i?

Can you clarify which code?

Nuckyz avatar May 18 '24 22:05 Nuckyz

now that f74da73 has been added, i'm pretty sure this can be fixed by using the same code that the new regex find uses for the match field as well @Nuckyz do you wanna add that or should i?

Can you clarify which code?

mainly the onFindBlur function and the findError/setFindError

and then instead of using CheckedTextInput for the match field we can use TextInput and reuse the functions above

waresnew avatar May 18 '24 23:05 waresnew

I mean yeah, but the problem of CheckedTextInput still needs to be fixed I guess

Nuckyz avatar May 18 '24 23:05 Nuckyz

I mean yeah, but the problem of CheckedTextInput still needs to be fixed I guess

we could just not use CheckedTextInput

since the Find field just uses TextInput and it achieves the same purpose (validating the regex and displaying an error)

waresnew avatar May 18 '24 23:05 waresnew

Okay I did the changes, super small but can someone review?

Nuckyz avatar May 19 '24 00:05 Nuckyz

it was crashing if you typed out an invalid regex (firing onMatchChange) so i added regex validation during the canoncalizeMatch() part

this way they can still type if it's invalid regex

waresnew avatar May 19 '24 00:05 waresnew

good catch, for some reason it worked fine in my tests

Nuckyz avatar May 19 '24 00:05 Nuckyz

Thanks for the effort of fixing it!

Nuckyz avatar May 19 '24 00:05 Nuckyz