mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Security Solution][Exceptions] - Fix empty selection showing for exception item field selection (#155221)
## Summary Addresses https://github.com/elastic/kibana/issues/145540 - blank space no longer shows as selection option for exception item field dropdown
This commit is contained in:
parent
ada91f9a5e
commit
afced9d47f
2 changed files with 51 additions and 3 deletions
|
@ -84,7 +84,56 @@ describe('useField', () => {
|
|||
expect(comboOptions).toEqual([{ label: 'bytes' }, { label: 'ssl' }, { label: '@timestamp' }]);
|
||||
expect(selectedComboOptions).toEqual([]);
|
||||
});
|
||||
it('should not return an empty field as a combo option', () => {
|
||||
it('should not return a selected field when empty string as a combo option', () => {
|
||||
const newIndexPattern = {
|
||||
...indexPattern,
|
||||
fields: [
|
||||
{
|
||||
name: 'bytes',
|
||||
type: 'number',
|
||||
esTypes: ['long'],
|
||||
count: 10,
|
||||
scripted: false,
|
||||
searchable: true,
|
||||
aggregatable: true,
|
||||
readFromDocValues: true,
|
||||
},
|
||||
{
|
||||
name: 'ssl',
|
||||
type: 'boolean',
|
||||
esTypes: ['boolean'],
|
||||
count: 20,
|
||||
scripted: false,
|
||||
searchable: true,
|
||||
aggregatable: true,
|
||||
readFromDocValues: true,
|
||||
},
|
||||
{
|
||||
name: '@timestamp',
|
||||
type: 'date',
|
||||
esTypes: ['date'],
|
||||
count: 30,
|
||||
scripted: false,
|
||||
searchable: true,
|
||||
aggregatable: true,
|
||||
readFromDocValues: true,
|
||||
},
|
||||
] as unknown as DataViewFieldBase[],
|
||||
title: 'title1',
|
||||
};
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
useField({
|
||||
indexPattern: newIndexPattern,
|
||||
onChange: onChangeMock,
|
||||
selectedField: { name: '', type: 'keyword' },
|
||||
})
|
||||
);
|
||||
const { comboOptions, selectedComboOptions } = result.current;
|
||||
expect(comboOptions).toEqual([{ label: 'bytes' }, { label: 'ssl' }, { label: '@timestamp' }]);
|
||||
expect(selectedComboOptions).toEqual([]);
|
||||
});
|
||||
it('should not return a selected field when string with spaces is written as a combo option', () => {
|
||||
const newIndexPattern = {
|
||||
...indexPattern,
|
||||
fields: [
|
||||
|
|
|
@ -26,14 +26,13 @@ import {
|
|||
GetFieldComboBoxPropsReturn,
|
||||
} from './types';
|
||||
import { disabledTypesWithTooltipText } from './disabled_types_with_tooltip_text';
|
||||
import { paramContainsSpace } from '../param_contains_space';
|
||||
|
||||
const getExistingFields = (indexPattern: DataViewBase | undefined): DataViewFieldBase[] => {
|
||||
return indexPattern != null ? indexPattern.fields : [];
|
||||
};
|
||||
|
||||
const getSelectedFields = (selectedField: DataViewField | undefined): DataViewFieldBase[] => {
|
||||
return selectedField && !paramContainsSpace(selectedField.name) ? [selectedField] : [];
|
||||
return selectedField && selectedField.name.trim() !== '' ? [selectedField] : [];
|
||||
};
|
||||
|
||||
const getAvailableFields = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue