From 939cdbc27bb2e0f20e7b6c450dcc1b9a539f140f Mon Sep 17 00:00:00 2001 From: Giovanni Lovato Date: Mon, 22 Feb 2021 16:36:51 +0100 Subject: [PATCH 1/2] Add disabled attribute --- src/vaadin-message-input.js | 14 ++++++++++++-- test/message-input.test.js | 12 ++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/vaadin-message-input.js b/src/vaadin-message-input.js index 54febe8..d7ee732 100644 --- a/src/vaadin-message-input.js +++ b/src/vaadin-message-input.js @@ -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 } }; } @@ -85,8 +95,8 @@ class MessageInputElement extends ElementMixin(ThemableMixin(PolymerElement)) { margin: 0; } - - [[i18n.send]] + + [[i18n.send]] `; } diff --git a/test/message-input.test.js b/test/message-input.test.js index 0f51814..25ce8e2 100644 --- a/test/message-input.test.js +++ b/test/message-input.test.js @@ -106,4 +106,16 @@ describe('message-input', () => { expect(textArea.inputElement.getAttribute('aria-label')).to.be.equal('Viesti'); }); }); + + describe('disabled attribute propagation', () => { + it('should be propagated to text-area', () => { + messageInput.disabled = true; + expect(textArea.getAttribute('disabled')).to.exist; + }); + + it('should be propagated to button', () => { + messageInput.disabled = true; + expect(button.getAttribute('disabled')).to.exist; + }); + }); }); From 71dbba3c47fd6a5a61930a6d1795824b2dd92278 Mon Sep 17 00:00:00 2001 From: Giovanni Lovato Date: Tue, 23 Feb 2021 09:28:17 +0100 Subject: [PATCH 2/2] Resolve review comments --- test/message-input.test.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/message-input.test.js b/test/message-input.test.js index 25ce8e2..7860e09 100644 --- a/test/message-input.test.js +++ b/test/message-input.test.js @@ -107,15 +107,24 @@ describe('message-input', () => { }); }); - describe('disabled attribute propagation', () => { + 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.getAttribute('disabled')).to.exist; + expect(textArea.disabled).to.be.true; }); it('should be propagated to button', () => { messageInput.disabled = true; - expect(button.getAttribute('disabled')).to.exist; + expect(button.disabled).to.be.true; }); }); });