Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix truncating spacing issue #2139

Merged
merged 1 commit into from
Nov 14, 2023
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 frontend/src/components/SimpleDropdownSelect.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.full-width {
width: 100%;
}

// remove this file when https://github.com/patternfly/patternfly/issues/6062 is solved
.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
andrewballantyne marked this conversation as resolved.
Show resolved Hide resolved
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
Loading