Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fix-segmented-control-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@audius/harmony": patch
"@audius/web": patch
---

Fix SegmentedControl text color being subdued on initial render when selected value doesn't match any option key
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export const SegmentedControl = <T extends string>(
const [localSelected, setLocalSelected] = useState(options[0]?.key ?? '')
const [maxOptionWidth, setMaxOptionWidth] = useState(0)

const selectedOption = selected ?? localSelected
const rawSelectedOption = selected ?? localSelected
// If the selected value doesn't match any option, fall back to the first option
const selectedOption =
options.some((option) => option.key === rawSelectedOption)
? rawSelectedOption
: options[0]?.key ?? rawSelectedOption

const onSetSelected = (option: T) => {
// Call props function if controlled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ export const TracksPreview = (props: TracksPreviewProps) => {
<SegmentedControl
label={messages.releaseType}
onSelectOption={handleOptionSelect}
selected={String(uploadType)}
selected={String(
uploadType === UploadType.INDIVIDUAL_TRACK
? UploadType.INDIVIDUAL_TRACKS
: uploadType
)}
options={[
{ key: String(UploadType.INDIVIDUAL_TRACKS), text: 'Tracks' },
{ key: String(UploadType.ALBUM), text: 'Album' },
Expand Down
Loading