fix(textarea): support placeholder (#578)
This commit is contained in:
parent
ce6a89c895
commit
79c51767af
2 changed files with 22 additions and 0 deletions
|
|
@ -24,6 +24,10 @@ export class LionTextarea extends LionField {
|
||||||
attribute: 'readonly',
|
attribute: 'readonly',
|
||||||
reflect: true,
|
reflect: true,
|
||||||
},
|
},
|
||||||
|
placeholder: {
|
||||||
|
type: String,
|
||||||
|
reflect: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,6 +83,13 @@ export class LionTextarea extends LionField {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changedProperties.has('placeholder')) {
|
||||||
|
const native = this._inputNode;
|
||||||
|
if (native) {
|
||||||
|
native.placeholder = this.placeholder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (changedProperties.has('modelValue')) {
|
if (changedProperties.has('modelValue')) {
|
||||||
this.resizeTextarea();
|
this.resizeTextarea();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,17 @@ describe('<lion-textarea>', () => {
|
||||||
.and.to.be.below(el.scrollHeight);
|
.and.to.be.below(el.scrollHeight);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('has an attribute that can be used to set the placeholder text of the textarea', async () => {
|
||||||
|
const el = await fixture(`<lion-textarea placeholder="text"></lion-textarea>`);
|
||||||
|
expect(el.getAttribute('placeholder')).to.equal('text');
|
||||||
|
expect(el._inputNode.getAttribute('placeholder')).to.equal('text');
|
||||||
|
|
||||||
|
el.placeholder = 'foo';
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(el.getAttribute('placeholder')).to.equal('foo');
|
||||||
|
expect(el._inputNode.getAttribute('placeholder')).to.equal('foo');
|
||||||
|
});
|
||||||
|
|
||||||
it('is accessible', async () => {
|
it('is accessible', async () => {
|
||||||
const el = await fixture(`<lion-textarea label="Label"></lion-textarea>`);
|
const el = await fixture(`<lion-textarea label="Label"></lion-textarea>`);
|
||||||
await expect(el).to.be.accessible();
|
await expect(el).to.be.accessible();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue