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

[text-area] Min/max rows attributes/properties #1399

Open
yuriy-fix opened this issue Nov 20, 2017 · 17 comments · May be fixed by vaadin/docs#3945
Open

[text-area] Min/max rows attributes/properties #1399

yuriy-fix opened this issue Nov 20, 2017 · 17 comments · May be fixed by vaadin/docs#3945
Assignees
Labels
DX Developer experience issue enhancement New feature or request vaadin-text-field

Comments

@yuriy-fix
Copy link
Contributor

Controlling the minimum and maximum height of the text-area is a common thing. Some DX/UX tests participants were expecting to see attributes for doing that. Should we introduce those or something like min-rows, max-rows that will be standing for height?

@jouni jouni changed the title Should we introduce an attribute for setting min/max height? Min/max height attributes/properties Nov 20, 2017
@jouni
Copy link
Member

jouni commented Nov 20, 2017

Let’s keep this as an enhancement request for now. Add your ”+1” reaction if you really need this.

@jouni
Copy link
Member

jouni commented Mar 9, 2018

The current way of controlling this is to use CSS min|max-height for the <vaadin-text-area> element.

vaadin-text-area {
  min-height: 100px;
  max-height: 300px;
}

See live examples: https://vaadin.com/components/vaadin-text-field/html-examples#text-area-demos

@tomivirkki tomivirkki changed the title Min/max height attributes/properties Min/max rows attributes/properties Jul 11, 2019
@lanmaster
Copy link

min-height: 10px;
didn't work

@jouni
Copy link
Member

jouni commented Oct 22, 2020

@lanmaster do mean that the field does not shrink to 10px? There's an issue about that: #1363

@netbeansuser2019
Copy link

So take to consideration:
vaadin/vaadin-text-field#506

@netbeansuser2019
Copy link

netbeansuser2019 commented Nov 18, 2020

Let me react to @jouni

There is simple use case as TextArea can be only scroll entirely then you cannot use well prefix and suffix component as it is hard to e.g. place any content into middle in such suffix or prefix, because if it is scrollable than such component ends out of visible area ... so if you need content to be possibly seen to user all the time ... like buttons, advice, status indicator, data indicator, and so on you can not do that for TextArea. So if you needed that you have to add extra wrapping so than there is not reason for suffix and prefix component at all if there is no simple way to adjust that. So if there is not expectation to turn back rows as in previous version Vaadin than I would like to suggest to be possible to turn on just scrolling of "input-area".

@jouni
Copy link
Member

jouni commented Nov 18, 2020

Thanks for the use case description, @netbeansuser2019!

To me it seems like that’s a separate topic, whether or not the prefix and suffix elements scroll together with the text content (vs how to control the sizing of <vaadin-text-area>).

If I understood correctly, I think what you are asking is for a way to directly pass the rows attribute to the internal <textarea> element. I don’t think we want to do that, as that exposes the internal implementation details of the component. That said, we could still offer an API to set the height limits as “rows”, for example with min-rows and max-rows attributes. How those would internally work, might be using the rows attribute on the textarea, but might be something else.

As for the other use case (scrolling), that could also be opt-in/out (like you mentioned in vaadin/vaadin-text-field#506 ). Though, I admit that I don’t remember any concrete use cases where you’d want the prefix/suffix element to scroll with the text.

Finally, as a workaround, you can achieve the desired scrolling behavior by using position: sticky;. Note, that it doesn’t work in IE11 or old Edge versions.

<vaadin-text-area>
  <div slot="prefix">Prefix</div>
</vaadin-text-area>

<style>
[slot="prefix"] {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
}
</style>

@netbeansuser2019
Copy link

I do not think so it could be fixed by "sticky" in case of "middle".

@jouni
Copy link
Member

jouni commented Dec 3, 2020

Not sure what you mean with ”middle” – can you elaborate?

@netbeansuser2019
Copy link

I mean like any icon shown in middle of visible area not in middle of entire scrollable area.

@jouni
Copy link
Member

jouni commented Dec 9, 2020

You mean like this?
Screen Shot 2020-12-09 at 14 56 59

That can be done like this:

[slot="prefix"] {
  position: -webkit-sticky;
  position: sticky;
  top: 50%;
  transform: translateY(-50%);
}

@netbeansuser2019
Copy link

Firstly this should be possible just from API.
If I used your code in https://www.w3schools.com/Css/tryit.asp?filename=trycss_position_sticky
so wrapped to DIV as styled as flex and no padding and set fixed size and overflow to scroll that has such two div-s inside such sticky one has never been in middle of visible area with new Edge and even FF, but ends on "the first line".

@jouni
Copy link
Member

jouni commented Dec 9, 2020

Hey, I’m just trying to help, provide a workaround 🤗 Perhaps it should be a built-in feature, but that’s probably not going to happen very soon, so we need to make due with workarounds until then.

I didn’t test this this in all sorts of situations, so there probably are cases where sticky doesn’t work like you’d want it to.

Would be great if you could provide example code. It’s a bit hard to understand the problem you described above.

@jouni
Copy link
Member

jouni commented Dec 9, 2020

I tried to replicate the case that you described, the best I understood. Feel free to ”remix” the example: https://glitch.com/~peppermint-rambunctious-entree

It does have an issue in Safari, where the sticky prefix element scrolls out of view (inside the text area) when you scroll far enough.

@vaadin-bot vaadin-bot transferred this issue from vaadin/vaadin-text-field May 19, 2021
@vlukashov vlukashov added DX Developer experience issue and removed DX tests finding labels May 19, 2021
@web-padawan web-padawan changed the title Min/max rows attributes/properties [text-area] Min/max rows attributes/properties May 20, 2021
@mil3stone
Copy link

Any update on including min-rows / max-rows for a fixed textarea height since the start of this issue back in 2017?

@OlliTietavainenVaadin
Copy link
Member

Workaround for Java, assuming there's an internal <textarea> element in light dom:

TextArea textArea = ...
textArea.getElement().executeJs("$0.getElementsByTagName('textarea')[0].setAttribute('rows','1');$0.getElementsByTagName('textarea')[0].style.minHeight = 0;", textArea.getElement());

@rolfsmeds
Copy link
Contributor

Although it's already been linked from this issue, I'll just reiterate that this is related to #1363

@rolfsmeds rolfsmeds moved this to Under consideration in Roadmap Nov 13, 2024
@sissbruecker sissbruecker linked a pull request Nov 22, 2024 that will close this issue
@rolfsmeds rolfsmeds moved this from Under consideration to December 2024 (24.6) in Roadmap Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Developer experience issue enhancement New feature or request vaadin-text-field
Projects
Status: December 2024 (24.6)
Development

Successfully merging a pull request may close this issue.

10 participants