mirror of
https://github.com/grafana/grafana.git
synced 2025-01-09 23:53:25 -06:00
Fix: Disables auto open datasource picker on focus (#16398)
This commit is contained in:
parent
80a170e62f
commit
a887c344eb
@ -1,9 +1,8 @@
|
|||||||
// Libraries
|
// Libraries
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import _ from 'lodash';
|
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { Select } from '@grafana/ui';
|
import { Select, SelectOptionItem } from '@grafana/ui';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { DataSourceSelectItem } from '@grafana/ui/src/types';
|
import { DataSourceSelectItem } from '@grafana/ui/src/types';
|
||||||
@ -14,26 +13,28 @@ export interface Props {
|
|||||||
current: DataSourceSelectItem;
|
current: DataSourceSelectItem;
|
||||||
onBlur?: () => void;
|
onBlur?: () => void;
|
||||||
autoFocus?: boolean;
|
autoFocus?: boolean;
|
||||||
|
openMenuOnFocus?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DataSourcePicker extends PureComponent<Props> {
|
export class DataSourcePicker extends PureComponent<Props> {
|
||||||
static defaultProps = {
|
static defaultProps: Partial<Props> = {
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
|
openMenuOnFocus: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
searchInput: HTMLElement;
|
searchInput: HTMLElement;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange = item => {
|
onChange = (item: SelectOptionItem) => {
|
||||||
const ds = this.props.datasources.find(ds => ds.name === item.value);
|
const ds = this.props.datasources.find(ds => ds.name === item.value);
|
||||||
this.props.onChange(ds);
|
this.props.onChange(ds);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { datasources, current, autoFocus, onBlur } = this.props;
|
const { datasources, current, autoFocus, onBlur, openMenuOnFocus } = this.props;
|
||||||
|
|
||||||
const options = datasources.map(ds => ({
|
const options = datasources.map(ds => ({
|
||||||
value: ds.name,
|
value: ds.name,
|
||||||
@ -58,7 +59,7 @@ export class DataSourcePicker extends PureComponent<Props> {
|
|||||||
options={options}
|
options={options}
|
||||||
autoFocus={autoFocus}
|
autoFocus={autoFocus}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
openMenuOnFocus={true}
|
openMenuOnFocus={openMenuOnFocus}
|
||||||
maxMenuHeight={500}
|
maxMenuHeight={500}
|
||||||
placeholder="Select datasource"
|
placeholder="Select datasource"
|
||||||
noOptionsMessage={() => 'No datasources found'}
|
noOptionsMessage={() => 'No datasources found'}
|
||||||
|
@ -152,6 +152,7 @@ export class QueriesTab extends PureComponent<Props, State> {
|
|||||||
current={null}
|
current={null}
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
onBlur={this.onMixedPickerBlur}
|
onBlur={this.onMixedPickerBlur}
|
||||||
|
openMenuOnFocus={true}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -408,8 +408,6 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleFocus = () => {};
|
|
||||||
|
|
||||||
onClickMenu = (item: CompletionItem) => {
|
onClickMenu = (item: CompletionItem) => {
|
||||||
// Manually triggering change
|
// Manually triggering change
|
||||||
const change = this.applyTypeahead(this.state.value.change(), item);
|
const change = this.applyTypeahead(this.state.value.change(), item);
|
||||||
@ -500,7 +498,6 @@ export class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldS
|
|||||||
onBlur={this.handleBlur}
|
onBlur={this.handleBlur}
|
||||||
onKeyDown={this.onKeyDown}
|
onKeyDown={this.onKeyDown}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
onFocus={this.handleFocus}
|
|
||||||
onPaste={this.handlePaste}
|
onPaste={this.handlePaste}
|
||||||
placeholder={this.props.placeholder}
|
placeholder={this.props.placeholder}
|
||||||
plugins={this.plugins}
|
plugins={this.plugins}
|
||||||
|
Loading…
Reference in New Issue
Block a user