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

feat: ✨ allow vertical resizing of node textareas #6180

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

joshistoast
Copy link
Contributor

Summary

Allows you to vertically resize textareas within the node editor and viewer. I was getting really tired of the restrictive viewing of my prompts within the workflows tab, so this pr addresses that.

Related Issues / Discussions

QA Instructions

Merge Plan

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable)

@github-actions github-actions bot added the frontend PRs that change frontend files label Apr 8, 2024
Copy link
Collaborator

@psychedelicious psychedelicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new size is forgotten if the component unmounts, because it is not recorded in the reactflow internal state.

reactflow provides a NodeResizer and customizable NodeResizeControl to implement resizing the whole node component. These allow for persistent node size changes. When I was last playing around with them, they didn't play very nicely with textareas.

Note that the width and height node properties are not writable - you must use the aforementioned utils to resize a node.

The textareas are purposefully not resizable to prevent bug reports about the size not being remembered.

Also - IIRC there is an edge case where the handles can end up offset vertically when resizing, but that may have been when you resize the node component.

I don't have any strong objections to changing it to allow resize but just wanted to add some context.

Also need to check how this might interact with the linear view, especially the drag and drop.

@joshistoast
Copy link
Contributor Author

Also need to check how this might interact with the linear view, especially the drag and drop.

I played with drag and drop with resizing and it worked surprisingly well.

I don't have any strong objections to changing it to allow resize but just wanted to add some context.

That's good context to have, and an restriction for that library to have. Maybe filing an issue on their repo could be beneficial.

@psychedelicious
Copy link
Collaborator

psychedelicious commented Apr 14, 2024

Actually, the width and height are recorded in the state. Resizing the text area updates these dimensions, but the nodes are all rendered and re-measured on mount, resetting the dimensions. There are existing issues in reactflow about this.

A solution might be to store the dimensions in our controlled data attribute on each node, then explicitly render the component at those dimensions. That should ensure the dimensions are measured correctly.

This would require adding the dimensions to zInvocationNodeData, zNotesNodeData and zCurrentImageNodeData as an optional property. <NodeWrapper /> would render the node with explicit width and height if present. Add handling in the nodesChanged reducer to check for changes of type "dimensions" and update the newly-added dimensions property for changed nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend PRs that change frontend files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants