Skip to content

Commit

Permalink
change input to textarea and use autosize on them (#7254)
Browse files Browse the repository at this point in the history
* change input to textarea and use autosize on them

* fix some tests
  • Loading branch information
meirish authored Aug 14, 2019
1 parent d158f26 commit 0bf1dad
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
11 changes: 11 additions & 0 deletions ui/lib/core/addon/components/string-list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ArrayProxy from '@ember/array/proxy';
import Component from '@ember/component';
import { set, computed } from '@ember/object';
import autosize from 'autosize';
import layout from '../templates/components/string-list';

export default Component.extend({
Expand Down Expand Up @@ -85,6 +86,16 @@ export default Component.extend({
this.send('addInput');
},

didInsertElement() {
this._super(...arguments);
autosize(this.element.querySelector('textarea'));
},

didUpdate() {
this._super(...arguments);
autosize.update(this.element.querySelector('textarea'));
},

setType() {
const list = this.inputList;
if (!list) {
Expand Down
3 changes: 1 addition & 2 deletions ui/lib/core/addon/templates/components/string-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
{{#each inputList as |data index|}}
<div class="field is-grouped" data-test-string-list-row="{{index}}">
<div class="control is-expanded">
{{input
{{textarea
data-test-string-list-input=index
type="text"
class="input"
value=data.value
name=(concat elementId "-" index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ module('Acceptance | settings/configure/secrets/pki/urls', function(hooks) {

await page.form.fields
.objectAt(0)
.input('foo')
.textarea('foo')
.change();
await page.form.submit();

assert.ok(page.form.hasError, 'shows error on invalid input');

await page.form.fields
.objectAt(0)
.input('foo.example.com')
.textarea('foo.example.com')
.change();
await page.form.submit();
assert.equal(page.lastMessage, 'The urls config for this backend has been updated.');
Expand Down
2 changes: 1 addition & 1 deletion ui/tests/integration/components/form-field-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module('Integration | Component | form field', function(hooks) {

await component.fields
.objectAt(0)
.input('array')
.textarea('array')
.change();
assert.deepEqual(model.get('foo'), ['array'], 'sets the value on the model');
assert.deepEqual(spy.args[0], ['foo', ['array']], 'onChange called with correct args');
Expand Down
2 changes: 1 addition & 1 deletion ui/tests/pages/components/form-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
input: fillable('input'),
select: fillable('select'),
textarea: fillable('textarea'),
change: triggerable('keyup', 'input'),
change: triggerable('keyup', '.input'),
inputValue: value('input'),
textareaValue: value('textarea'),
inputChecked: attribute('checked', 'input[type=checkbox]'),
Expand Down
2 changes: 1 addition & 1 deletion ui/tests/pages/secrets/backend/pki/edit-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default create({
toggleOptions: clickable('[data-test-toggle-group="Options"]'),
name: fillable('[data-test-input="name"]'),
allowAnyName: clickable('[data-test-input="allowAnyName"]'),
allowedDomains: fillable('[data-test-input="allowedDomains"] input'),
allowedDomains: fillable('[data-test-input="allowedDomains"] .input'),
save: clickable('[data-test-role-create]'),

createRole(name, allowedDomains) {
Expand Down

0 comments on commit 0bf1dad

Please sign in to comment.