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

feat: add disabled property to vaadin-message-input #44

Merged
merged 2 commits into from
Feb 23, 2021
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
14 changes: 12 additions & 2 deletions src/vaadin-message-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ class MessageInputElement extends ElementMixin(ThemableMixin(PolymerElement)) {
message: 'Message'
}),
observer: '__i18nChanged'
},

/**
* Set to true to disable this element.
* @type {boolean}
*/
disabled: {
type: Boolean,
value: false,
reflectToAttribute: true
web-padawan marked this conversation as resolved.
Show resolved Hide resolved
}
};
}
Expand All @@ -85,8 +95,8 @@ class MessageInputElement extends ElementMixin(ThemableMixin(PolymerElement)) {
margin: 0;
}
</style>
<vaadin-text-area value="{{value}}" placeholder="[[i18n.message]]"></vaadin-text-area>
<vaadin-button theme="primary contained" on-click="__submit">[[i18n.send]]</vaadin-button>
<vaadin-text-area disabled="[[disabled]]" value="{{value}}" placeholder="[[i18n.message]]"></vaadin-text-area>
<vaadin-button disabled="[[disabled]]" theme="primary contained" on-click="__submit">[[i18n.send]]</vaadin-button>
`;
}

Expand Down
21 changes: 21 additions & 0 deletions test/message-input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,25 @@ describe('message-input', () => {
expect(textArea.inputElement.getAttribute('aria-label')).to.be.equal('Viesti');
});
});

describe('disabled property', () => {
it('should be false by default', () => {
expect(messageInput.disabled).to.be.false;
});

it('should be reflected to the attribute', () => {
messageInput.disabled = true;
expect(messageInput.getAttribute('disabled')).to.exist;
});

it('should be propagated to text-area', () => {
messageInput.disabled = true;
expect(textArea.disabled).to.be.true;
});

it('should be propagated to button', () => {
messageInput.disabled = true;
expect(button.disabled).to.be.true;
});
});
});