mmo
mmo

Reputation: 4246

How to set a TextArea read-only (but scrollable)?

How does one set a TextArea as read-only?

I have a longer text-field that I want to display but which should be read-only for certain user-roles, i.e. not modifiable. It should however remain scrollable (because its contents can be much longer than what is visible). It should behave like a "normal" TextArea, but only some users should be able to actually modify its content.

TextArea has a method setReadOnly(boolean) which I first thought to provide exactly that functionality, but it seems to be a no-op, at least I don't see any effect from setting it. The method setEnabled(boolean) on the other hand makes the text-area readonly, but also non-scrollable, which makes it unusable for my purpose.

Any suggestion? This is using Vaadin v20.0.1

Upvotes: 0

Views: 638

Answers (2)

mmo
mmo

Reputation: 4246

(Blush!) I have to back-paddle! The setReadOnly()-method DOES work as expected! My boolean expression that I had used to toggle it turned out to be always false. The problem was in front of the glass - not behind! Apologies for the bandwidth wasted!

Upvotes: 0

Jouni
Jouni

Reputation: 2918

TextArea should support the readonly state just like a single line TextField, and the web component <vaadin-text-area readonly> works as expected. Please report a bug at https://github.com/vaadin/flow-components/issues/new/choose

Upvotes: 1

Related Questions