Skip to content

Commit

Permalink
fix truncating spacing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Gkrumbach07 committed Nov 14, 2023
1 parent b13896b commit 56c29ed
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
5 changes: 5 additions & 0 deletions frontend/src/components/SimpleDropdownSelect.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.full-width {
width: 100%;
}

.truncate-no-min-width {
--pf-c-truncate--MinWidth: 0;
--pf-c-truncate__start--MinWidth: 0;
}
15 changes: 7 additions & 8 deletions frontend/src/components/SimpleDropdownSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import './SimpleDropdownSelect.scss';

export type SimpleDropdownOption = {
key: string;
label: React.ReactNode;
label: string;
description?: React.ReactNode;
selectedLabel?: React.ReactNode;
dropdownLabel?: React.ReactNode;
isPlaceholder?: boolean;
};

Expand All @@ -29,9 +29,8 @@ const SimpleDropdownSelect: React.FC<SimpleDropdownProps> = ({
...props
}) => {
const [open, setOpen] = React.useState(false);

const selectedOption = options.find(({ key }) => key === value);
const selectedLabel = selectedOption?.selectedLabel ?? selectedOption?.label ?? placeholder;
const selectedLabel = selectedOption?.label ?? placeholder;

return (
<Dropdown
Expand All @@ -44,12 +43,12 @@ const SimpleDropdownSelect: React.FC<SimpleDropdownProps> = ({
className={isFullWidth ? 'full-width' : undefined}
onToggle={() => setOpen(!open)}
>
<Truncate content={selectedLabel.toString()} style={{ paddingLeft: 0 }} />
<Truncate content={selectedLabel} className="truncate-no-min-width" />
</DropdownToggle>
}
dropdownItems={options
dropdownItems={[...options]
.sort((a, b) => (a.isPlaceholder === b.isPlaceholder ? 0 : a.isPlaceholder ? -1 : 1))
.map(({ key, label, description, isPlaceholder }) => (
.map(({ key, dropdownLabel, label, description, isPlaceholder }) => (
<DropdownItem
key={key}
description={description}
Expand All @@ -58,7 +57,7 @@ const SimpleDropdownSelect: React.FC<SimpleDropdownProps> = ({
setOpen(false);
}}
>
{label}
{dropdownLabel ?? label}
</DropdownItem>
))}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const ServingRuntimeTemplateSection: React.FC<ServingRuntimeTemplateSectionProps
}) => {
const options = templates.map((template) => ({
key: getServingRuntimeNameFromTemplate(template),
selectedLabel: getServingRuntimeDisplayNameFromTemplate(template),
label: (
label: getServingRuntimeDisplayNameFromTemplate(template),
dropdownLabel: (
<Split>
<SplitItem>
{<Truncate content={getServingRuntimeDisplayNameFromTemplate(template)} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ const AcceleratorSelectField: React.FC<AcceleratorSelectFieldProps> = ({

return {
key: ac.metadata.name,
selectedLabel: displayName,
label: displayName,
description: ac.spec.description,
label: (
dropdownLabel: (
<Split>
<SplitItem>{displayName}</SplitItem>
<SplitItem isFilled />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const ImageStreamSelector: React.FC<ImageStreamSelectorProps> = ({

return {
key: imageStream.metadata.name,
selectedLabel: displayName,
label: displayName,
description: description,
disabled: !checkImageStreamAvailability(imageStream, buildStatuses),
label: (
dropdownLabel: (
<Split>
<SplitItem>{displayName}</SplitItem>
<SplitItem isFilled />
Expand Down

0 comments on commit 56c29ed

Please sign in to comment.