Skip to content

Commit

Permalink
modify propDebouncedOnChange
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshatJawne committed May 30, 2024
1 parent 241116a commit db94f61
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/ui/src/js/src/elements/spectrum/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
TextField as DHCTextField,
TextFieldProps as DHCTextFieldProps,
} from '@deephaven/components';
import Log from '@deephaven/log';
import { useDebouncedCallback, usePrevious } from '@deephaven/react-hooks';

const VALUE_CHANGE_DEBOUNCE = 250;
Expand Down Expand Up @@ -35,8 +36,12 @@ function TextField(props: TextFieldProps): JSX.Element {
}

const propDebouncedOnChange = useCallback(
(newValue: string) => {
propOnChange(newValue);
async (newValue: string) => {
try {
await propOnChange(newValue);
} catch (e) {
Log.warn('Error returned from onChange', e);
}
setPending(false);
},
[propOnChange]
Expand All @@ -49,8 +54,8 @@ function TextField(props: TextFieldProps): JSX.Element {

const onChange = useCallback(
(newValue: string) => {
debouncedOnChange(newValue);
setPending(true);
debouncedOnChange(newValue);
setValue(newValue);
},
[debouncedOnChange]
Expand Down

0 comments on commit db94f61

Please sign in to comment.