Skip to content

fix(editor): make TextareaAutocomplete fully controlled to prevent update loops - #1940

Merged
feruzm merged 2 commits into
developfrom
seer/fix/textarea-autocomplete-update-depth
Oct 10, 2026
Merged

feruzm merged 2 commits into
developfrom
seer/fix/textarea-autocomplete-update-depth

Conversation

@sentry

@sentry sentry Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What was changed

In apps/web/src/features/shared/textarea-autocomplete/index.tsx, removed the duplicated local value state and the useEffect that kept re-syncing props.value into it. TextareaAutocomplete is now fully controlled: it passes props.value ?? "" straight down to ReactTextareaAutocomplete and forwards change events via props.onChange without updating local state.

Why

TextareaAutocomplete maintained a local value mirror initialized from props.value, and ran:

useEffect(() => {
  setValue(props.value);
}, [props.value, value]);

Because the local value was included in the dependency array, any edit (e.g. typing or pasting an image, which dispatches a synthetic change event from insertOrReplace) called setValue(event.target.value) inside handleChange, immediately re-triggering the effect to write props.value back. In callers like /submit and the comment reply box—where the parent already holds controlled state (body / text)—the ping-pong between local state and the incoming prop produced back-to-back synchronous updates that exceeded React's maximum update depth (error #185).

Making the component purely controlled removes the redundant state copy and eliminates the update loop entirely.

Fixes ECENCY-NEXT-1GRK

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@feruzm
feruzm merged commit 31b444b into develop Oct 10, 2026
8 checks passed
@feruzm
feruzm deleted the seer/fix/textarea-autocomplete-update-depth branch October 10, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant