Skip to content

Fix SegmentedControl to handle invalid selected values gracefully#14059

Merged
dylanjeffers merged 2 commits intomainfrom
claude/fix-segmented-control-text-gpT72
Apr 5, 2026
Merged

Fix SegmentedControl to handle invalid selected values gracefully#14059
dylanjeffers merged 2 commits intomainfrom
claude/fix-segmented-control-text-gpT72

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Summary

This PR adds validation to the SegmentedControl component to gracefully handle cases where the selected value doesn't match any available option, and fixes a bug in TracksPreview where an invalid enum value was being passed.

Key Changes

  • SegmentedControl: Added fallback logic to validate that the selected value exists in the options list. If the selected value is invalid, it falls back to the first available option instead of rendering an unmatched state.
  • TracksPreview: Fixed a bug where UploadType.INDIVIDUAL_TRACK (singular) was being passed to SegmentedControl, but the available options only included UploadType.INDIVIDUAL_TRACKS (plural). Added a mapping to convert the singular enum value to the plural one that matches the available options.

Implementation Details

  • The SegmentedControl now performs an options.some() check to verify the selected value exists before using it
  • If validation fails, it safely falls back to options[0]?.key or the raw selected value as a last resort
  • This prevents UI inconsistencies and ensures the component always renders in a valid state

https://claude.ai/code/session_01S8Yn3jaHMpAZ2LRKDoDPfA

When uploadType is INDIVIDUAL_TRACK (0), the selected value doesn't match
any option key in TracksPreview's SegmentedControl (which only has
INDIVIDUAL_TRACKS=1, ALBUM=3, PLAYLIST=2). The pill falls back to index 0
visually, but isSelected stays false for all options, making all text subdued.

Fix by mapping INDIVIDUAL_TRACK to INDIVIDUAL_TRACKS in TracksPreview, and
adding a fallback in SegmentedControl to select the first option when the
selected value doesn't match any option key.

https://claude.ai/code/session_01S8Yn3jaHMpAZ2LRKDoDPfA
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 5, 2026

🦋 Changeset detected

Latest commit: cb3aa3a

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

This PR includes changesets to release 2 packages
Name Type
@audius/harmony Patch
@audius/web 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

@dylanjeffers dylanjeffers merged commit 1ec251b into main Apr 5, 2026
9 checks passed
@dylanjeffers dylanjeffers deleted the claude/fix-segmented-control-text-gpT72 branch April 5, 2026 00:06
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

🌐 Web preview ready

Preview URL: https://audius-web-preview-pr-14059.audius.workers.dev

Unique preview for this PR (deployed from this branch).
Workflow run

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants