MarketTrend: aggressive default field matching (#41574)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { ComponentType } from 'react';
|
||||
import {
|
||||
DataLink,
|
||||
Field,
|
||||
@@ -171,11 +170,6 @@ export interface StatsPickerConfigSettings {
|
||||
defaultStat?: string;
|
||||
}
|
||||
|
||||
interface FieldNamePickerInfoProps {
|
||||
name?: string;
|
||||
field?: Field;
|
||||
}
|
||||
|
||||
export interface FieldNamePickerConfigSettings {
|
||||
/**
|
||||
* Function is a predicate, to test each element of the array.
|
||||
@@ -188,13 +182,7 @@ export interface FieldNamePickerConfigSettings {
|
||||
*/
|
||||
noFieldsMessage?: string;
|
||||
|
||||
/**
|
||||
* When a field is selected, this component can show aditional
|
||||
* information, including validation etc
|
||||
*/
|
||||
info?: ComponentType<FieldNamePickerInfoProps> | null;
|
||||
|
||||
/**
|
||||
/**addFieldNamePicker
|
||||
* Sets the width to a pixel value.
|
||||
*/
|
||||
width?: number;
|
||||
|
||||
@@ -15,11 +15,11 @@ export const FieldNamePicker: React.FC<StandardEditorProps<string, FieldNamePick
|
||||
const selectOptions = useSelectOptions(names, value);
|
||||
|
||||
const onSelectChange = useCallback(
|
||||
(selection: SelectableValue<string>) => {
|
||||
if (!frameHasName(selection.value, names)) {
|
||||
return;
|
||||
(selection?: SelectableValue<string>) => {
|
||||
if (selection && !frameHasName(selection.value, names)) {
|
||||
return; // can not select name that does not exist?
|
||||
}
|
||||
return onChange(selection.value!);
|
||||
return onChange(selection?.value);
|
||||
},
|
||||
[names, onChange]
|
||||
);
|
||||
@@ -35,8 +35,8 @@ export const FieldNamePicker: React.FC<StandardEditorProps<string, FieldNamePick
|
||||
onChange={onSelectChange}
|
||||
noOptionsMessage={settings.noFieldsMessage}
|
||||
width={settings.width}
|
||||
isClearable={true}
|
||||
/>
|
||||
{settings.info && <settings.info name={value} field={names.fields.get(value)} />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user