Fix null reference TypeScript error - searchInput

This commit is contained in:
Dmitry Lyzo 2022-02-16 21:52:06 +03:00
parent 9c7ba63696
commit a08f8e3f75

View File

@ -57,6 +57,11 @@ const SearchFields: FunctionComponent<SearchFieldsProps> = ({ onSearch = () => {
const value = (e as CustomEvent).detail.value;
const searchInput = getSearchInput();
if (!searchInput) {
console.error('Unexpected null reference');
return;
}
if (value === 'backspace') {
const currentValue = searchInput.value;
searchInput.value = currentValue.length ? currentValue.substring(0, currentValue.length - 1) : '';