Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: autocomplete input change #58

Merged
merged 2 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@euk-labs/componentz",
"version": "0.4.2",
"version": "0.4.3",
"main": "./cjs/index.js",
"module": "./index.js",
"types": "./index.d.ts",
Expand Down
11 changes: 8 additions & 3 deletions src/components/Inputs/Autocomplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TextFieldProps,
createFilterOptions,
debounce as muiDebounce,
AutocompleteInputChangeReason,
} from '@mui/material';
import React, { useCallback } from 'react';

Expand Down Expand Up @@ -75,9 +76,13 @@ function Autocomplete<T>({
[]
);

function handleInputChange(value: string) {
function handleInputChange(
event: React.SyntheticEvent,
value: string,
reason: AutocompleteInputChangeReason
) {
if (!debounce) {
return null;
return props.onInputChange && props.onInputChange(event, value, reason);
}

if (onDebouncedInputChange) {
Expand All @@ -92,7 +97,7 @@ function Autocomplete<T>({
fullWidth
filterOptions={props.filterOptions || defaultFilterOptions(buildNew)}
loading={props.loading}
onInputChange={(e, value) => handleInputChange(value)}
onInputChange={handleInputChange}
renderOption={checkbox ? withCheckboxOptionRenderer : undefined}
renderInput={(params) => (
<TextField
Expand Down