Merge pull request #198 from mario-aleo/fix/textareaDisableUserResize

[textarea] Disable user resize behavior
This commit is contained in:
Mikhail Bashkirov 2019-07-24 11:21:50 +02:00 committed by GitHub
commit 5a60e80433
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -40,7 +40,16 @@ export class LionTextarea extends ObserverMixin(LionInput) {
get slots() {
return {
...super.slots,
input: () => document.createElement('textarea'),
input: () => {
const input = document.createElement('textarea');
// disable user resize behavior if browser supports it
if (input.style.resize !== undefined) {
input.style.resize = 'none';
}
return input;
},
};
}

View file

@ -2,6 +2,11 @@ import { expect, fixture, html } from '@open-wc/testing';
import '../lion-textarea.js';
function hasBrowserResizeSupport() {
const textarea = document.createElement('textarea');
return textarea.style.resize !== undefined;
}
describe('<lion-textarea>', () => {
it(`can be used with the following declaration
~~~
@ -17,6 +22,16 @@ describe('<lion-textarea>', () => {
expect(el.maxRows).to.equal(6);
});
it('disables user resize behavior', async () => {
if (!hasBrowserResizeSupport()) {
return;
}
const el = await fixture(`<lion-textarea></lion-textarea>`);
const computedStyle = window.getComputedStyle(el.inputElement);
expect(computedStyle.resize).to.equal('none');
});
it('supports initial modelValue', async () => {
const el = await fixture(
html`