react-sortable-tree icon indicating copy to clipboard operation
react-sortable-tree copied to clipboard

Dynamic row height depending on amount of lines in text

Open pixxelia opened this issue 4 years ago • 12 comments

how can the height of the items be set dynamically based on the text size (e.g. number of lines or calculated item height)?

pixxelia avatar May 25 '20 14:05 pixxelia

@pixxelia did you get any solution for this?

anil1712 avatar Jun 11 '20 12:06 anil1712

@pixxelia did you get any solution for this?

no :-( did you?

pixxelia avatar Jun 11 '20 12:06 pixxelia

@pixxelia did you get any solution for this?

no :-( did you?

Not yet 👎

anil1712 avatar Jun 12 '20 04:06 anil1712

will take a look

lifejuggler avatar Jun 19 '20 04:06 lifejuggler

Thanks @lifejuggler It would be better if we get the same for the width.

anil1712 avatar Jun 19 '20 06:06 anil1712

I don't follow @anil1712 why we'd need dynamic row width

lifejuggler avatar Jun 19 '20 14:06 lifejuggler

I don't follow @anil1712 why we'd need dynamic row width

Please see the attached screenshot, in my case the texts are getting overlapped. Screen Shot 2020-06-20 at 11 28 10 PM

So may be if we manage the width based on the content then it would be better

anil1712 avatar Jun 20 '20 17:06 anil1712

maybe but if I do add the width its not going to be for this issue

lifejuggler avatar Jun 22 '20 01:06 lifejuggler

Looking forward to getting this fixed. The usability is lost when one uses the plugin to render dynamic components.

p8ul avatar Jul 24 '20 08:07 p8ul

Please take a look at this PR https://github.com/frontend-collective/react-sortable-tree/pull/774. I solved the dynamic row height and I will look forward to your suggestions now.

topolanekmartin avatar Aug 11 '20 14:08 topolanekmartin

How do we achieve the dynamic height?

billyz313 avatar Dec 15 '20 19:12 billyz313

We can use some dirty solution, while PR #774 not merged.

Create a custom theme based on default theme. Add custom attribute to element with rst__rowLabel class with treeIndex value.

 <div className={classnames('rst__rowLabel', rowDirectionClass)} dataid={treeIndex}>

Write rowHeight function

rowHeight: ({ treeIndex }) => {
    const treeEl = document.querySelector(`[dataid="${treeIndex}"]`);
    return treeEl ? treeEl.offsetHeight : 0;
  },

Do not forget change rst__rowLabel class, so that it has the height of the content.

Gerpea avatar Mar 29 '21 12:03 Gerpea