mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Fleet] Fix host input with empty value (#101178)
This commit is contained in:
parent
e607b58590
commit
66553681c0
2 changed files with 14 additions and 1 deletions
|
@ -66,3 +66,12 @@ test('it should allow to update existing host with multiple hosts', async () =>
|
|||
fireEvent.change(inputEl, { target: { value: 'http://newhost.com' } });
|
||||
expect(mockOnChange).toHaveBeenCalledWith(['http://newhost.com', 'http://host2.com']);
|
||||
});
|
||||
|
||||
test('it should render an input if there is not hosts', async () => {
|
||||
const { utils, mockOnChange } = renderInput([]);
|
||||
|
||||
const inputEl = await utils.findByDisplayValue('');
|
||||
expect(inputEl).toBeDefined();
|
||||
fireEvent.change(inputEl, { target: { value: 'http://newhost.com' } });
|
||||
expect(mockOnChange).toHaveBeenCalledWith(['http://newhost.com']);
|
||||
});
|
||||
|
|
|
@ -132,7 +132,7 @@ const SortableTextField: FunctionComponent<SortableTextFieldProps> = React.memo(
|
|||
|
||||
export const HostsInput: FunctionComponent<Props> = ({
|
||||
id,
|
||||
value,
|
||||
value: valueFromProps,
|
||||
onChange,
|
||||
helpText,
|
||||
label,
|
||||
|
@ -140,6 +140,10 @@ export const HostsInput: FunctionComponent<Props> = ({
|
|||
errors,
|
||||
}) => {
|
||||
const [autoFocus, setAutoFocus] = useState(false);
|
||||
const value = useMemo(() => {
|
||||
return valueFromProps.length ? valueFromProps : [''];
|
||||
}, [valueFromProps]);
|
||||
|
||||
const rows = useMemo(
|
||||
() =>
|
||||
value.map((host, idx) => ({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue