Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 7 additions & 1 deletion code/core/src/components/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ export interface SelectProps
onSelect?: (option: Value) => void;
onDeselect?: (option: Value) => void;
onChange?: (selected: Value[]) => void;
/**
* Whether to show the selected option's title in place of the children when an option is
* selected. Defaults to true.
*/
showSelectedLabel?: boolean;
}

function valueToId(parentId: string, { value }: InternalOption | ResetOption): string {
Expand Down Expand Up @@ -200,6 +205,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(
onChange,
tooltip,
ariaLabel,
showSelectedLabel = true,
...props
},
ref
Expand Down Expand Up @@ -501,7 +507,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(
{!multiSelect && (
<>
{icon}
{selectedOptions[0]?.title ?? children}
{(showSelectedLabel && selectedOptions[0]?.title) || children}
</>
)}

Expand Down
1 change: 1 addition & 0 deletions code/core/src/toolbar/components/ToolbarMenuSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const ToolbarMenuSelect: FC<ToolbarMenuSelectProps> = withKeyboardCycle(
onReset={() => updateGlobals({ [id]: '_reset' })}
onSelect={(selected) => updateGlobals({ [id]: selected })}
icon={icon && <Icons icon={icon} __suppressDeprecationWarning={true} />}
showSelectedLabel={false}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
showSelectedLabel={false}
showSelectedLabel={dynamicTitle}

otherwise it'll never update

>
{title}
</Select>
Expand Down
Loading