Skip to content

Conversation

@boughtabigk1
Copy link
Contributor

@boughtabigk1 boughtabigk1 commented Dec 25, 2025

The bug: shortly after opening ps, roughly coinciding with your login (maybe related to user data being loaded from server? don't know why these are connected) the main ps server sends the client a protocol message containing all valid formats. when the client receives this, it re-renders the format button with the new formats. the issue is that when it does that, it does it by REPLACING the format button with a new one, but the code which selects formats relies on stored references to the format select pop up menu's original format button. the result of this is that the format button doesn't exist if formats have been updated since opening the drop down menu, so nothing happens when you select the format. It will stay on random battles, and if you pick another format again, it will keep the randomized format team preview.

Recreate bug: go into ps and open the ladder format menu immediately after the site opens. wait for your username to populate in the top right. then select a non-randomized format from the opened format menu. you should see that nothing happens

The fix: store a reference to the drop down form (this is stable even if updateFormats is called) and dynamically find the format button when necessary so we can set the html of the current button, not the dead reference.

Notes: it's probably generally best to update buttons rather than replace them to avoid these sorts of DOM reference issues, but I'm not good with frontend, and this was the only fix I could manage without refactoring lots of other peoples' code. I also haven't noticed any other instances of DOM reference bugs other than this one.

@boughtabigk1
Copy link
Contributor Author

pretty sure this is a super old bug, identified here and here

@Zarel Zarel merged commit 13ed416 into smogon:master Dec 26, 2025
1 check passed
@Zarel
Copy link
Member

Zarel commented Dec 26, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants