Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
abailly-akamai committed Dec 11, 2024
1 parent c9e9b45 commit 9686103
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 0 additions & 3 deletions packages/manager/src/features/Managed/MonitorDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ const MonitorDrawer = (props: MonitorDrawerProps) => {
data-qa-add-consultation-group
errorText={errors.consultation_group}
label="Contact Group"
// name="consultation_group"
onBlur={handleBlur}
options={groupOptions}
placeholder="Select a group..."
Expand All @@ -198,7 +197,6 @@ const MonitorDrawer = (props: MonitorDrawerProps) => {
data-qa-add-service-type
errorText={errors.service_type}
label="Monitor Type"
// name="service_type"
onBlur={handleBlur}
options={typeOptions}
value={getValueFromItem(values.service_type, typeOptions)}
Expand Down Expand Up @@ -280,7 +278,6 @@ const MonitorDrawer = (props: MonitorDrawerProps) => {
errorText={errors.credentials}
label="Credentials"
multiple
// name="credentials"
onBlur={handleBlur}
options={credentialOptions}
/>
Expand Down
17 changes: 12 additions & 5 deletions packages/ui/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,20 @@ const getOptions = ({ creatable, inputValue, options }: GetOptionsProps) => {
return [{ label: 'No options available', noOptions: true, value: '' }];
}

if (
inputValue &&
!options.some((opt) => opt.value === inputValue || opt.label === inputValue)
) {
if (inputValue) {
const matchingOptions = options.filter(
(opt) =>
opt.label.toLowerCase().includes(inputValue.toLowerCase()) ||
opt.value.toLowerCase().includes(inputValue.toLowerCase())
);

if (!matchingOptions.length) {
return [{ create: true, label: inputValue, value: inputValue }];
}

return [
{ create: true, label: inputValue, value: inputValue },
...options,
...matchingOptions,
].sort((a, b) => {
if (a.create) {
return -1;
Expand Down

0 comments on commit 9686103

Please sign in to comment.