-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
Expose row count information #271
Comments
What you could also leverage is the current count of rendered |
Hmm, how do I get that value? |
It's not available right now, I was just wondering if that would be enough for you to handle your use case. In general, I have deliberately removed this extra argument in v8 so I could gather feedback and use cases from consumers of this package so I could add it back knowing more and potentially providing a better API. |
Ah I see, yeah that makes sense. As for the value that we need for our use case, we basically need to know the number of rows yes, so that we can show/hide the expand/collapse button. How do you plan to proceed here? |
I will try to give this a thought soon and comment back, but don't have a better solution right now in my mind than just adding an extra argument to |
Thanks, hopefully we can figure something out. |
If you can work with the currently rendered amount of rows (and not with the amount of "value rows") then I think adding this to |
Can you clarify the difference between the amount of "rows" and the amount of "value rows"? For us it's important to know if we need to show the expand/collapse button. This means that if the input has 3 rows and I click on "collapse", I only see the "first" row. However, the "expand" button should be visible because in reality there are 3 rows (2 of them are hidden). |
"rows" - matching native If you need to know the latter ("value rows") then I'm not sure if the best place for it would be I haven't thought about it extensively so I could have missed something - but I can't see when (in your use case) would you need "value rows" instead of "rows". Could you describe the situation when having just "rows" would fail? |
So if I do this: const MultilineInput = (props) => {
const ref = React.useRef();
const { onHeightChange } = props;
const handleHeightChange = React.useCallback(
(height) => {
console.log('rows', ref.current.rows);
onHeightChange(height);
},
[onHeightChange]
);
return (
<TextareaAutosize
ref={ref}
// ...
/>
);
}; The If that's what you had in mind, I'm afraid it doesn't work and the value I need is the "value rows".
I think so too, it should probably something separate. |
You are accessing I just have thought about an alternative solution. We could expose
I understand this would include more boilerplate on your side but would also be more generic solution, accommodating for more use cases to be covered with it. WDYT? |
@Andarist Sounds good to me. How do you wish to expose the |
A second argument ( |
I opened a PR with your suggestion. |
@Andarist FYI: the new meta option works as expected, I was able to restore the previous behavior. |
Glad to hear that 👍 |
Hi,
we're trying to migrate to v8 but we realized that the change in
onHeightChange
function arguments is causing us to miss on a key feature.Background
In our UI components library we have a component called
MultilineTextInput
, which uses the resizable textarea component. One of the features of this component is that when there is value in more than one line, we show an expand/collapse button.You can see a live example here: https://uikit.commercetools.com/?path=/story/components-inputs--multilinetextinput
To do that, we rely on the
valueRowCount
exposed by the component.https://github.com/commercetools/ui-kit/blob/86a85e642d0d47089c3ddd7094974c58badbed56/src/components/inputs/multiline-text-input/multiline-text-input.js#L30-L40
In v8 though, the
onHeightChange
only exposes theheight
value.Ideally, what we need is the internally calculated
rowHeight
react-textarea-autosize/src/calculateNodeHeight.ts
Line 50 in 757355d
And to calculate the row count:
Proposal
I'm not sure what the best solution here would be. Maybe we can introduce a new callback prop that specifically exposes this value.
What do you think? Do you see any other solution?
I'm happy to work on a PR if we decide how to proceed.
Thanks!
The text was updated successfully, but these errors were encountered: