Select: Replace dropdown indicator with loading icon (#105739)
* Replace the dropdown icon with loading to reduce jankiness * Rmove theme usage * Remove unused import * Fix margin issue * Update snapshot
This commit is contained in:
@@ -275,7 +275,6 @@ export const getInputStyles = stylesFactory(({ theme, invalid = false, width }:
|
|||||||
label: 'input-suffix',
|
label: 'input-suffix',
|
||||||
paddingLeft: theme.spacing(1),
|
paddingLeft: theme.spacing(1),
|
||||||
paddingRight: theme.spacing(1),
|
paddingRight: theme.spacing(1),
|
||||||
marginBottom: '-2px',
|
|
||||||
borderLeft: 'none',
|
borderLeft: 'none',
|
||||||
borderTopLeftRadius: 0,
|
borderTopLeftRadius: 0,
|
||||||
borderBottomLeftRadius: 0,
|
borderBottomLeftRadius: 0,
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
import { DropdownIndicatorProps } from 'react-select';
|
import { DropdownIndicatorProps } from 'react-select';
|
||||||
|
|
||||||
import { Icon } from '../Icon/Icon';
|
import { Icon } from '../Icon/Icon';
|
||||||
|
import { Spinner } from '../Spinner/Spinner';
|
||||||
|
|
||||||
export function DropdownIndicator({ selectProps }: DropdownIndicatorProps) {
|
export function DropdownIndicator({ selectProps }: DropdownIndicatorProps) {
|
||||||
const isOpen = selectProps.menuIsOpen;
|
const isOpen = selectProps.menuIsOpen;
|
||||||
const icon = isOpen ? 'search' : 'angle-down';
|
const icon = isOpen ? 'search' : 'angle-down';
|
||||||
const size = 'md';
|
const size = 'md';
|
||||||
|
|
||||||
|
if (selectProps.isLoading) {
|
||||||
|
return <Spinner inline />;
|
||||||
|
}
|
||||||
|
|
||||||
return <Icon name={icon} size={size} />;
|
return <Icon name={icon} size={size} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import { SelectableValue, toOption } from '@grafana/data';
|
|||||||
import { useTheme2 } from '../../themes';
|
import { useTheme2 } from '../../themes';
|
||||||
import { t, Trans } from '../../utils/i18n';
|
import { t, Trans } from '../../utils/i18n';
|
||||||
import { Icon } from '../Icon/Icon';
|
import { Icon } from '../Icon/Icon';
|
||||||
import { Spinner } from '../Spinner/Spinner';
|
|
||||||
|
|
||||||
import { CustomInput } from './CustomInput';
|
import { CustomInput } from './CustomInput';
|
||||||
import { DropdownIndicator } from './DropdownIndicator';
|
import { DropdownIndicator } from './DropdownIndicator';
|
||||||
@@ -364,7 +363,8 @@ export function SelectBase<T, Rest = {}>({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
LoadingIndicator() {
|
LoadingIndicator() {
|
||||||
return <Spinner inline />;
|
// Handled with DropdownIndicator, to avoid resize flickering with auto width
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
LoadingMessage() {
|
LoadingMessage() {
|
||||||
return <div className={styles.loadingMessage}>{loadingMessage}</div>;
|
return <div className={styles.loadingMessage}>{loadingMessage}</div>;
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ export const Spinner = ({
|
|||||||
const getStyles = (theme: GrafanaTheme2) => ({
|
const getStyles = (theme: GrafanaTheme2) => ({
|
||||||
inline: css({
|
inline: css({
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
|
lineHeight: 0,
|
||||||
}),
|
}),
|
||||||
spin: css({
|
spin: css({
|
||||||
[theme.transitions.handleMotion('no-preference')]: {
|
[theme.transitions.handleMotion('no-preference')]: {
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ exports[`VariableQueryEditor renders correctly 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="css-zyjsuv-input-suffix"
|
class="css-1h17wob-input-suffix"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
|
|||||||
Reference in New Issue
Block a user