diff --git a/lib/zin/wg/stepseditor/js/v1.js b/lib/zin/wg/stepseditor/js/v1.js index 0cf87e343c..80ab9b466f 100644 --- a/lib/zin/wg/stepseditor/js/v1.js +++ b/lib/zin/wg/stepseditor/js/v1.js @@ -291,7 +291,8 @@ class StepsEditor extends zui.Component { const options = this.options; let $row = $rows.filter(`[data-id="${item.id}"]`); - if(!$row.length) $row = this._createRow(item, options); + let isNew = !$row.length; + if(isNew) $row = this._createRow(item, options); if($preRow) $row.insertAfter($preRow); else $list.prepend($row); @@ -303,20 +304,22 @@ class StepsEditor extends zui.Component .toggleClass('has-children', hasSub) .toggleClass('no-child', !hasSub) .removeClass('is-expired'); - $row.css('--name-indent', `${(item.level - 1) * 14}px`).find('.steps-editor-step-name').css('width', item.name.length * 12).text(item.name).css('paddingLeft', (item.level - 1) * 14); - $row.find('.steps-editor-step-text').attr('name', `${options.name}[${item.name}]`); - $row.find('.steps-editor-step-type').attr('name', `stepType[${item.name}]`).val(hasSub ? 'group' : (!!item.parent && item.parent != '0' ? 'item' : 'step')); - if(options.postDataID) $row.find('.steps-editor-post-data-id').attr('name', `id[${item.name}]`); - const $expect = $row.find('.steps-editor-step-expect').attr( - { - name: `${options.expectsName}[${item.name}]`, - disabled: hasSub && options.expectDisabled ? 'disabled' : null - }).toggleClass('disabled', hasSub && options.expectDisabled); - $expect.parent().toggleClass('disabled', hasSub && options.expectDisabled); - $row.find('.steps-editor-col-delete .btn').toggleClass('disabled', hasSub || this._items.length == 1); - $row.find('.steps-editor-col-delete .btn.disabled').attr('title', options.deleteStepTip); - $row.find('.steps-editor-col-add .btn-action[data-action="sub"]').toggleClass('disabled', item.level >= 3); - $row.find('textarea').autoHeight(); + requestAnimationFrame(() => { + $row.css('--name-indent', `${(item.level - 1) * 14}px`).find('.steps-editor-step-name').css('width', item.name.length * 12).text(item.name).css('paddingLeft', (item.level - 1) * 14); + $row.find('.steps-editor-step-text').attr('name', `${options.name}[${item.name}]`); + $row.find('.steps-editor-step-type').attr('name', `stepType[${item.name}]`).val(hasSub ? 'group' : (!!item.parent && item.parent != '0' ? 'item' : 'step')); + if(options.postDataID) $row.find('.steps-editor-post-data-id').attr('name', `id[${item.name}]`); + const $expect = $row.find('.steps-editor-step-expect').attr( + { + name: `${options.expectsName}[${item.name}]`, + disabled: hasSub && options.expectDisabled ? 'disabled' : null + }).toggleClass('disabled', hasSub && options.expectDisabled); + $expect.parent().toggleClass('disabled', hasSub && options.expectDisabled); + $row.find('.steps-editor-col-delete .btn').toggleClass('disabled', hasSub || this._items.length == 1); + $row.find('.steps-editor-col-delete .btn.disabled').attr('title', options.deleteStepTip); + $row.find('.steps-editor-col-add .btn-action[data-action="sub"]').toggleClass('disabled', item.level >= 3); + if(isNew) $row.find('textarea').autoHeight({fast: true}); + }); return $row; }