Skip to content

Commit

Permalink
added useEffect and isClearable
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Dec 6, 2022
1 parent 261b8f9 commit 31506ac
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { EuiComboBox } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

Expand All @@ -22,7 +22,9 @@ export const DatasetComboBox: React.FC<{
},
]);

if (!value) onChange(defaultOption);
useEffect(() => {
if (!value) onChange(defaultOption);
}, [value, defaultOption, onChange]);

const onDatasetChange = (newSelectedOptions: Array<{ label: string }>) => {
setSelectedOptions(newSelectedOptions);
Expand Down Expand Up @@ -58,6 +60,7 @@ export const DatasetComboBox: React.FC<{
defaultMessage: 'Add {searchValue} as a custom option',
values: { searchValue: '{searchValue}' },
})}
isClearable={false}
/>
);
};

0 comments on commit 31506ac

Please sign in to comment.