Skip to content

Commit

Permalink
fix: text input default value (#958)
Browse files Browse the repository at this point in the history
- Fixes #948 
- Since `defaultValue` is passed to `useDebouncedOnChange` as
`propValue`, `onChange` should be returned so the value can be edited
  • Loading branch information
wusteven815 authored Oct 25, 2024
1 parent 1fac6af commit 0ac72be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/ui/src/js/src/elements/hooks/useDebouncedOnChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const VALUE_CHANGE_DEBOUNCE = 250;
function useDebouncedOnChange<T>(
propValue: T,
propOnChange: (() => void) | ((newValue: T) => Promise<void>) | undefined
): [T, ((newValue: T) => void) | undefined] {
): [T, (newValue: T) => void] {
const [value, setValue] = useState<T>(propValue);
const [pending, setPending] = useState(false);
const prevPropValue = usePrevious(propValue);
Expand Down Expand Up @@ -50,7 +50,7 @@ function useDebouncedOnChange<T>(
[debouncedOnChange]
);

return [value, propOnChange != null ? onChange : undefined] as const;
return [value, onChange] as const;
}

export default useDebouncedOnChange;

0 comments on commit 0ac72be

Please sign in to comment.