Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change input to textarea and use autosize on them #7254

Merged
merged 2 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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