Skip to content

Fix multiple text tracks being selectable in the language menu - #189

Merged
MattiasBuelens merged 2 commits into
mainfrom
devin/1789538074-fix-multiple-text-tracks
Sep 16, 2026
Merged

MattiasBuelens merged 2 commits into
mainfrom
devin/1789538074-fix-multiple-text-tracks

Conversation

@MattiasBuelens

Copy link
Copy Markdown
Collaborator

Summary

Fixes #187: selecting a second subtitle track in <theoplayer-language-menu> did not deselect the first one, so multiple tracks were shown at the same time.

This worked in v1 and regressed in v2 with the introduction of RadioGroup.value (bc8188e). In v2, _onButtonChange only did this.value = button.value. Track buttons (TextTrackRadioButton, TextTrackOffRadioButton, MediaTrackRadioButton) do not set a value, so they all share undefined. The value setter returns early when the value is unchanged, and never unchecks the previously checked button.

Fix in RadioGroup:

 private readonly _onButtonChange = (event: Event) => {
     const button = event.target as RadioButton | null;
-    if (button !== null && button.checked) {
-        this.value = button.value;
-    }
+    if (button === null || !button.checked) return;
+    this._value = button.value;
+    this.setCheckedRadioButton(button);   // always uncheck the other buttons, like v1 did
+    this.dispatchEvent(createEvent('change', { bubbles: true }));
 };

 private updateCheckedButton(): void {
+    if (this._value === undefined) return;  // value-less buttons manage their own checked state
     ...
 }

The guard in updateCheckedButton() prevents find(b => b.value == undefined) from checking the first (e.g. "Off") button on slot change, which would otherwise disable a track that is showing by default.

Groups with explicit values (PlaybackRateRadioGroup, text track style menus) are unaffected: their value setter still drives updateCheckedButton().

Verification

  • npm run test:format, test:typecheck, test:unit, build:debug pass.
  • Verified in headless Chrome with examples/default-ui.html and a source with two WebVTT tracks (English, German): before the fix, clicking English then German left both tracks showing; after the fix only the last clicked track is showing, and "Off" disables both. A track with default: true stays selected on load.

Link to Devin session: https://dolby.devinenterprise.com/sessions/4a87b8e21d9344fc8c5e6a918b5ab471
Open in Devin Desktop: https://dolby.devinenterprise.com/desktop/session/4a87b8e21d9344fc8c5e6a918b5ab471?variant=devin
Requested by: @MattiasBuelens

Fixes #187

Co-Authored-By: Mattias Buelens <mattias.buelens@dolby.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@changeset-bot

changeset-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 18d1f8a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@theoplayer/web-ui Patch
@theoplayer/react-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-Authored-By: Mattias Buelens <mattias.buelens@dolby.com>
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review September 16, 2026 06:10
@MattiasBuelens MattiasBuelens added the bug Something isn't working label Sep 16, 2026
@MattiasBuelens
MattiasBuelens merged commit 1dcb14c into main Sep 16, 2026
1 check passed
@MattiasBuelens
MattiasBuelens deleted the devin/1789538074-fix-multiple-text-tracks branch September 16, 2026 09:52
@theoplayer-bot theoplayer-bot Bot mentioned this pull request Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can select multiple text track languages

2 participants