diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/pipeline_select.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/pipeline_select.tsx index 1a682d37e439d..9295c5440a054 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/pipeline_select.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/pipelines/ml_inference/pipeline_select.tsx @@ -5,11 +5,11 @@ * 2.0. */ -import React from 'react'; +import React, { useState } from 'react'; import { useActions, useValues } from 'kea'; -import { EuiSelectable, useIsWithinMaxBreakpoint } from '@elastic/eui'; +import { EuiSelectable, useEuiTheme, useIsWithinMaxBreakpoint } from '@elastic/eui'; import { MLInferenceLogic, MLInferencePipelineOption } from './ml_inference_logic'; import { PipelineSelectOption, PipelineSelectOptionProps } from './pipeline_select_option'; @@ -23,6 +23,15 @@ export const PipelineSelect: React.FC = () => { const { pipelineName } = configuration; + const { euiTheme } = useEuiTheme(); + const largeScreenRowHeight = euiTheme.base * 6; + const smallScreenRowHeight = euiTheme.base * 8; + const maxVisibleOptions = 4.5; + const rowHeight: number = useIsWithinMaxBreakpoint('s') + ? smallScreenRowHeight + : largeScreenRowHeight; + const [height, setHeight] = useState(maxVisibleOptions * rowHeight); + const getPipelineOptions = ( pipelineOptions: MLInferencePipelineOption[] ): PipelineSelectOptionProps[] => { @@ -50,14 +59,20 @@ export const PipelineSelect: React.FC = () => { options={getPipelineOptions(existingInferencePipelines)} listProps={{ bordered: true, - rowHeight: useIsWithinMaxBreakpoint('s') ? 120 : 90, showIcons: true, onFocusBadge: false, + rowHeight, + }} + searchProps={{ + onChange: (_, matchingOptions) => { + setHeight(Math.min(maxVisibleOptions, matchingOptions.length) * rowHeight); + }, }} searchable singleSelection="always" onChange={onChange} renderOption={renderPipelineOption} + height={height} > {(list, search) => ( <>