question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling `setNodes` doesn't update nodes - Trying to make a Node height dynamic based on textarea input size

See original GitHub issue

I’m submitting a…

[x] Bug report

I’m trying to make a node height update when the height of the textarea changes.

Video walkthrough: https://youtu.be/Ar_SKdDnAz8

image

image

Implementation of updateCurrentNode: https://github.com/Vadorequest/poc-nextjs-reaflow/blob/repro-textarea-dyn-height/src/components/PlaygroundContainer.tsx#L97-L113

Current behavior

Calling setNodes doesn’t seem to update nodes every time. Sometimes it’s “updated” (but the UI doesn’t reflect the change, though).

I can’t tell if it’s a react issue (like, my code), or something related to Reaflow itself. What’s weirdest is that the re-render doesn’t propagate to children component (EditorContainer renders, but PlaygroundContainer doesn’t seem so, but I can’t explain why)

Also, I wonder if there is a utility function to update an existing node in an array of nodes. I couldn’t find any example/demo on how to do that.

I wonder if I need to use an actual state manager to avoid those kinds of issues.

Expected behavior

The state should update in EditorContainer every time the height of the textarea changes, and it should re-render all children components and recalculate the position of all the elements in the Canvas.

Minimal reproduction of the problem with instructions

Run locally:

  • git clone https://github.com/Vadorequest/poc-nextjs-reaflow.git
  • cd poc-nextjs-reaflow && git checkout repro-textarea-dyn-height
  • yarn && yarn start

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
amcdnlcommented, Mar 1, 2021

change detection

0reactions
Vadorequestcommented, Feb 25, 2021

Yes - it should be immutable in order for CD to work.

@amcdnl What does CD means here? 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a textarea with auto-resize - javascript - Stack Overflow
When injecting content into a textarea via JavaScript append the following code to invoke the function in option 1. $("textarea").trigger("input");. PRESET ...
Read more >
How to expand node's size dynamically when the text in its ...
I want to dynamically expand/shrink the size of Node depending upon the length of characters being entered in the textBlock of Node.
Read more >
Normalizing - Slate
If two adjacent text nodes have the same formatting, they're merged into a single text node with a combined text string of the...
Read more >
Node (JavaFX 8) - Oracle Help Center
Base class for scene graph nodes. A scene graph is a set of tree data structures where every item has zero or one...
Read more >
Auto-Growing Inputs & Textareas | CSS-Tricks
Get started with $200 in free credit! By default, <input> and <textarea> elements don't change size based on the content they contain.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found