Home

# Class goog.ui.Textarea

A textarea control to handle growing/shrinking with textarea.value.

extends goog.ui.Control

Instance Method Summary

`discoverTextareaCharacteristics_()`

In order to assess the correct height for a textarea, we need to know whether the scrollHeight (the full height of the text) property includes the values for padding and borders. We can also test whether the box-sizing: border-box setting is working and then tweak accordingly. Instead of hardcoding a list of currently known behaviors and testing for quirksmode, we do a runtime check out of the flow. The performance impact should be very small.

| `enterDocument()` Configures the component after its DOM has been rendered, and sets up event handling. Overrides {@link goog.ui.Component#enterDocument}.
| `getHeight_() ⇒ number` Gets the textarea's content height + padding height + border height. This is done by getting the scrollHeight and adjusting from there. In the end this result is what we want the new offsetHeight to equal.
| `getHorizontalScrollBarHeight_() ⇒ number` Gets the the height of (possibly present) horizontal scrollbar.
| `getMaxHeight() ⇒ number`
| `getMaxHeight_() ⇒ number`
| `getMinHeight() ⇒ number`
| `getMinHeight_() ⇒ number`
| `getPaddingBorderBoxHeight_() ⇒ number`
| `getValue() ⇒ string` Gets the textarea's value.
| `grow_(?goog.events.Event= opt_e)` Resizes the textarea to grow/shrink to match its contents.
| `mouseUpListener_(?goog.events.BrowserEvent e)` We use this listener to check if the textarea has been natively resized and if so we reset minHeight so that we don't ever shrink smaller than the user's manually set height. Note that we cannot check size on mousedown and then just compare here because we cannot capture mousedown on the textarea resizer, while mouseup fires reliably.
| `resize()` Resizes the textarea vertically.
| `setContent(?goog.ui.ControlContent content)` Sets the component's content to the given text caption, element, or array of nodes. (If the argument is an array of nodes, it must be an actual array, not an array-like object.)

`setEnabled(boolean enable)`

Enables or disables the component. Does nothing if this state transition is disallowed. If the component is both visible and focusable, updates its focused state and tab index as needed. If the component is being disabled, ensures that it is also deactivated and un-highlighted first. Note that the component's enabled/disabled state is "locked" as long as it is hosted in a {@link goog.ui.Container} that is itself disabled; this is to prevent clients from accidentally re-enabling a control that is in a disabled container.

| `setHeightToEstimate_()` Sets the textarea's rows attribute to be the number of newlines + 1. This is necessary when the textarea is hidden, in which case scrollHeight is not available.
| `setHeight_(number height)` Sets the textarea's height.
| `setMaxHeight(number height)` Sets a minimum height for the textarea, and calls resize if rendered.
| `setMinHeight(number height)` Sets a minimum height for the textarea, and calls resize if rendered.
| `setValue(<Any Type> value)` Sets the textarea's value.
| `shrink_()` Resizes the texarea to shrink to fit its contents. The way this works is by increasing the padding of the textarea by 1px (it's important here that we're in box-sizing: border-box mode). If the size of the textarea grows, then the box is filled up to the padding box with text. If it doesn't change, then we can shrink.