mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 17:52:55 +00:00
Set textarea height to fit content
This commit is contained in:
@@ -106,8 +106,11 @@ export function uiRawTagEditor(context) {
|
||||
|
||||
wrap.selectAll('.raw-tag-option')
|
||||
.classed('selected', function(datum) { return datum === d; });
|
||||
|
||||
wrap.selectAll('.tag-text')
|
||||
.classed('hide', (d.id !== 'text'));
|
||||
.classed('hide', (d.id !== 'text'))
|
||||
.each(setTextareaHeight);
|
||||
|
||||
wrap.selectAll('.tag-list, .add-row')
|
||||
.classed('hide', (d.id !== 'list'));
|
||||
})
|
||||
@@ -128,8 +131,9 @@ export function uiRawTagEditor(context) {
|
||||
.merge(textarea);
|
||||
|
||||
textarea
|
||||
.attr('rows', rowData.length + 1)
|
||||
.call(utilGetSetValue, rowsToText(rowData))
|
||||
.each(setTextareaHeight)
|
||||
.on('input', setTextareaHeight)
|
||||
.on('blur', textChanged)
|
||||
.on('change', textChanged);
|
||||
|
||||
@@ -281,6 +285,15 @@ export function uiRawTagEditor(context) {
|
||||
}
|
||||
|
||||
|
||||
function setTextareaHeight() {
|
||||
if (_tagView !== 'text') return;
|
||||
|
||||
var selection = d3_select(this);
|
||||
selection.style('height', null);
|
||||
selection.style('height', selection.node().scrollHeight + 5 + 'px');
|
||||
}
|
||||
|
||||
|
||||
function rowsToText(rows) {
|
||||
return rows
|
||||
.filter(function(row) { return row.key && row.key.trim() !== ''; })
|
||||
|
||||
Reference in New Issue
Block a user