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

bug: TextField.TextArea's size does not update when value is set externally #484

Open
andrerocco opened this issue Sep 4, 2024 · 0 comments

Comments

@andrerocco
Copy link

andrerocco commented Sep 4, 2024

Describe the bug

The TextField.TextArea component is not triggering a resize when the text signal changes by its setter. This means that when the content of the textarea is updated programmatically, the component doesn't automatically adjust its height as expected.

To Reproduce

Steps to reproduce the behavior:

  1. Create a TextField.TextArea component with the autoResize prop set to true.
  2. Set up a signal to control the textarea's content (using the value prop).
  3. Update the signal's value programmatically (e.g., through a button click or effect).
  4. Observe that the textarea's height does not adjust to fit the new content.

Demo: https://stackblitz.com/edit/github-b14x5v-a9ch1g?file=src%2FApp.tsx

Expected behavior

When the content of the TextFieldTextArea is updated either through user input or programmatically via a signal, the component should automatically resize to fit the new content if the autoResize prop is set to true.

Screenshots

Screen.Recording.2024-09-04.at.00.07.06.mov

Desktop:

  • OS: MacOS Sonoma 14.5
  • Browser: Arc
  • Version: 1.57.1 (Chromium version 128.0.6613.85)

Additional context

Listening to the value prop passed to TextFieldTextArea will fix the problem. In the means of:

createEffect(
	on(
		[() => ref, () => local.autoResize, () => context.value(), () => others.value],
		([ref, autoResize]) => {
			if (!ref || !autoResize) {
				return;
			}

			adjustHeight(ref);
		},
	),
);
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

No branches or pull requests

1 participant