[Report] textarea minHeight handling
In many TiddlyTools add-ons (see list below), I have used the following syntax to create autosizing textareas that default to a single row:
```
<$edit-text tag=textarea field=... class=tc-edit-texteditor rows=1 minHeight=1em autoHeight=yes .../>
```
In TW5.3.8, the textarea appears as a single line until either a newline is entered or the field content wraps, at which point the textarea begins to grow vertically to fit the content. However, in TW5.4.0, the textarea is ALWAYS a single row, even if it contains newlines or the content wraps.
The difference is due https://github.com/TiddlyWiki/TiddlyWiki5/pull/9454, which changed one line in `$:/core/modules/editor/engines/simple.js`.
In TW5.3.8, line 103 was:
```
if(this.widget.editTag === "textarea") {
```
while in TW5.4.0, this line (and preceding comment) is:
```
// If .editRows is initialised, it takes precedence
if((this.widget.editTag === "textarea") && !this.widget.editRows) {
```
Reverting the above change to `simple.js` fixes the problem (i.e, the textarea height grows as needed to fit the content).
Alternatively, if I remove the `rows=1` param from my `$edit-text` usage, then `autoHeight=yes` is applied successfully and the textarea height grows as needed to fit the content. **_However, the minimum height of the resulting textareas then all appear to be at least 2 rows tall, even though `minHeight=1em` has been specified in the `$edit-text` widget._**
Note that the actual setting of the textarea height is calculated and performed by `$tw.utils.resizeTextAreaToFit()`, which is in `$:/core/modules/utils/dom.js`.
This issue affects all of the following TiddlyTools add-ons:
* TiddlyTools/Cookies/Manager
* TiddlyTools/Editable
* TiddlyTools/Macros/edit-list/Examples
* TiddlyTools/Palettes/Backgrounds
* TiddlyTools/Panels/Browser
* TiddlyTools/PasteUp/Edit
* TiddlyTools/Search/Filters
* TiddlyTools/Search/TagCloud
* TiddlyTools/Templates/Description
* TiddlyTools/Time/Calendar
* Welcome
Please accept my profound apologies for not having found this issue sooner. Of course, I am willing to change all of the above TiddlyTools add-ons to remove the `rows=1` param, as long as I can get the "default to single-row and grow as needed" display handling to work as desired.
For a simple test:
1. Import https://tiddlytools.com/#TiddlyTools%2FTemplates%2FDescription into an empty TW5.4.0 file.
2. Create a new tiddler. Note that the custom "description" field (that appears just below the standard `text` field textarea) will always be one row tall, even if you enter text containing newlines.
3. Then, edit `TiddlyTools/Templates/Description` and remove the `rows=1` param from the `$edit-text` widget.
4. Create a new tiddler. Note that the custom "description" field now appears to be initially 2 rows tall, and will grow taller as you enter text containing newlines.
11 条评论