Skip to content

Commit 9988e07

Browse files
mario-aleoMikhail Bashkirov
authored andcommitted
fix(textarea): disable user resize behavior (fix #165)
1 parent da99c69 commit 9988e07

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

packages/textarea/src/LionTextarea.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ export class LionTextarea extends ObserverMixin(LionInput) {
4040
get slots() {
4141
return {
4242
...super.slots,
43-
input: () => document.createElement('textarea'),
43+
input: () => {
44+
const input = document.createElement('textarea');
45+
46+
// disable user resize behavior if browser supports it
47+
if (input.style.resize !== undefined) {
48+
input.style.resize = 'none';
49+
}
50+
51+
return input;
52+
},
4453
};
4554
}
4655

packages/textarea/test/lion-textarea.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { expect, fixture, html } from '@open-wc/testing';
22

33
import '../lion-textarea.js';
44

5+
function hasBrowserResizeSupport() {
6+
const textarea = document.createElement('textarea');
7+
return textarea.style.resize !== undefined;
8+
}
9+
510
describe('<lion-textarea>', () => {
611
it(`can be used with the following declaration
712
~~~
@@ -17,6 +22,16 @@ describe('<lion-textarea>', () => {
1722
expect(el.maxRows).to.equal(6);
1823
});
1924

25+
it('disables user resize behavior', async () => {
26+
if (!hasBrowserResizeSupport()) {
27+
return;
28+
}
29+
30+
const el = await fixture(`<lion-textarea></lion-textarea>`);
31+
const computedStyle = window.getComputedStyle(el.inputElement);
32+
expect(computedStyle.resize).to.equal('none');
33+
});
34+
2035
it('supports initial modelValue', async () => {
2136
const el = await fixture(
2237
html`

0 commit comments

Comments
 (0)