Skip to content

fix(team participants): multiple card group toggles not working on same page#7044

Merged
Rathoz merged 1 commit intomainfrom
multi-toggle-fix
Feb 4, 2026
Merged

fix(team participants): multiple card group toggles not working on same page#7044
Rathoz merged 1 commit intomainfrom
multi-toggle-fix

Conversation

@Eetwalt
Copy link
Collaborator

@Eetwalt Eetwalt commented Feb 4, 2026

Summary

Problem:
The Show All Toggle Buttons break if there's multiple present. (E.g in some cases the TeamParticpants will be split up due to there being groups / sections to split them off into.

See https://liquipedia.net/deadlock/User:Kanoodles/Testcase#Participants

SwitchButtons.js originally only registered the first toggle it found for a given data-switch-group. When the page had multiple CardsGroups using the same group names (team-cards-show-rosters, team-cards-compact), the later toggles were never added to the switch group and never got click listeners.

This PR makes switch groups collect and manage all DOM nodes that share the same data-switch-group:

  • When scanning the page, every matching toggle is added into the existing switch group (with deduping).
  • Click listeners are only bound once per node (so re-running init doesn’t double-bind).
  • Newly-discovered nodes are immediately synced to the current switch value so all toggles stay visually and functionally linked.

How did you test this change?

dev tools

screenrecording-2026-02-04_13-38-19.mp4

@Eetwalt Eetwalt requested review from a team and Rathoz February 4, 2026 11:40
@Eetwalt Eetwalt added the javascript Changes to JavaScript files label Feb 4, 2026
Copilot AI review requested due to automatic review settings February 4, 2026 11:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where multiple toggle buttons with the same data-switch-group on a page would fail to work correctly. Previously, only the first toggle in each group was registered and received click listeners.

Changes:

  • Refactored switch group initialization to collect all DOM nodes sharing the same data-switch-group
  • Added deduplication logic using Set and WeakSet to prevent duplicate nodes and double-binding of event listeners
  • Ensured newly discovered nodes sync to the current switch value for consistent visual state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hjpalpha
Copy link
Collaborator

hjpalpha commented Feb 4, 2026

fwiw #6986 would also mitigate this to some degree :P

Copy link
Collaborator

@hjpalpha hjpalpha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable on phone

@Eetwalt
Copy link
Collaborator Author

Eetwalt commented Feb 4, 2026

fwiw #6986 would also mitigate this to some degree :P

Sure, this will also prevent such cases in the future, not just this specific problem. And in some cases people might not want to wrap the cards in dynamic tabs

Doesn't hurt to have both IMO

@Rathoz Rathoz merged commit 57b8923 into main Feb 4, 2026
6 checks passed
@Rathoz Rathoz deleted the multi-toggle-fix branch February 4, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: team_participant javascript Changes to JavaScript files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants