GrafanaUI: Fix Combobox ignoring loading prop (#105584)
fix(Combobox): show loading state when loading prop is true Closes #105294
This commit is contained in:
@@ -11,6 +11,7 @@ import { Input, Props as InputProps } from '../Input/Input';
|
|||||||
import { Portal } from '../Portal/Portal';
|
import { Portal } from '../Portal/Portal';
|
||||||
|
|
||||||
import { ComboboxList } from './ComboboxList';
|
import { ComboboxList } from './ComboboxList';
|
||||||
|
import { SuffixIcon } from './SuffixIcon';
|
||||||
import { itemToString } from './filter';
|
import { itemToString } from './filter';
|
||||||
import { getComboboxStyles, MENU_OPTION_HEIGHT, MENU_OPTION_HEIGHT_DESCRIPTION } from './getComboboxStyles';
|
import { getComboboxStyles, MENU_OPTION_HEIGHT, MENU_OPTION_HEIGHT_DESCRIPTION } from './getComboboxStyles';
|
||||||
import { ComboboxOption } from './types';
|
import { ComboboxOption } from './types';
|
||||||
@@ -129,7 +130,6 @@ export const Combobox = <T extends string | number>(props: ComboboxProps<T>) =>
|
|||||||
autoFocus,
|
autoFocus,
|
||||||
onBlur,
|
onBlur,
|
||||||
disabled,
|
disabled,
|
||||||
loading,
|
|
||||||
invalid,
|
invalid,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
@@ -330,12 +330,7 @@ export const Combobox = <T extends string | number>(props: ComboboxProps<T>) =>
|
|||||||
const InputComponent = isAutoSize ? AutoSizeInput : Input;
|
const InputComponent = isAutoSize ? AutoSizeInput : Input;
|
||||||
const placeholder = (isOpen ? itemToString(selectedItem) : null) || placeholderProp;
|
const placeholder = (isOpen ? itemToString(selectedItem) : null) || placeholderProp;
|
||||||
|
|
||||||
const suffixIcon = asyncLoading
|
const loading = props.loading || asyncLoading;
|
||||||
? 'spinner'
|
|
||||||
: // If it's loading, show loading icon. Otherwise, icon indicating menu state
|
|
||||||
isOpen
|
|
||||||
? 'search'
|
|
||||||
: 'angle-down';
|
|
||||||
|
|
||||||
const inputSuffix = (
|
const inputSuffix = (
|
||||||
<>
|
<>
|
||||||
@@ -357,7 +352,7 @@ export const Combobox = <T extends string | number>(props: ComboboxProps<T>) =>
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Icon name={suffixIcon} />
|
<SuffixIcon isLoading={loading || false} isOpen={isOpen} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -369,7 +364,6 @@ export const Combobox = <T extends string | number>(props: ComboboxProps<T>) =>
|
|||||||
autoFocus={autoFocus}
|
autoFocus={autoFocus}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
loading={loading}
|
|
||||||
invalid={invalid}
|
invalid={invalid}
|
||||||
className={styles.input}
|
className={styles.input}
|
||||||
suffix={inputSuffix}
|
suffix={inputSuffix}
|
||||||
|
|||||||
Reference in New Issue
Block a user