this.onChoiceClick(item)}>
-
{item.caption}
-
{item.value}
+
{item?.caption}
+
{item?.value}
);
};
- private onChoiceClick = (item: Item): void => {
- this.props.onNewValue(item.caption);
+ private onChoiceClick = (item?: Item): void => {
+ this.props.onNewValue(item?.caption);
this.setState({ isSuggestionVisible: false, selectedChoice: item });
};
- private handleChange = (value: string): void => {
+ private handleChange = (value?: string): void => {
if (!value) {
this.setState({ isSuggestionVisible: true });
}
@@ -130,7 +130,7 @@ export class InputTypeaheadComponent extends React.Component<
}
};
- private filterChoiceByValue = (choices: Item[], searchKeyword: string): Item[] => {
+ private filterChoiceByValue = (choices: Item[], searchKeyword?: string): Item[] => {
return choices.filter((choice) =>
// @ts-ignore
Object.keys(choice).some((key) => choice[key].toLowerCase().includes(searchKeyword.toLowerCase()))
@@ -138,7 +138,7 @@ export class InputTypeaheadComponent extends React.Component<
};
public render(): JSX.Element {
- const { defaultValue, useTextarea, placeholder, onNewValue } = this.props;
+ const { defaultValue, useTextarea, placeholder, onNewValue, submitFct } = this.props;
const { isSuggestionVisible, selectedChoice, filteredChoices } = this.state;
const theme = getTheme();
@@ -185,7 +185,7 @@ export class InputTypeaheadComponent extends React.Component<
styles={iconButtonStyles}
iconProps={searchIcon}
ariaLabel="Search Button"
- onClick={() => this.props.submitFct(defaultValue, selectedChoice)}
+ onClick={() => submitFct && submitFct(defaultValue, selectedChoice)}
/>
)}
diff --git a/tsconfig.strict.json b/tsconfig.strict.json
index ee037db87..0b6e8c05b 100644
--- a/tsconfig.strict.json
+++ b/tsconfig.strict.json
@@ -8,6 +8,8 @@
"noUnusedParameters": true
},
"files": [
+ "./src/Explorer/Controls/InputTypeahead/InputTypeaheadComponent.tsx",
+ "./src/Explorer/Controls/InputTypeahead/InputTypeaheadComponent.test.tsx",
"./src/AuthType.ts",
"./src/Bindings/ReactBindingHandler.ts",
"./src/Common/ArrayHashMap.ts",
@@ -165,4 +167,4 @@
"src/Terminal/**/*",
"src/Utils/arm/**/*"
]
-}
+}
\ No newline at end of file