Skip to content

Commit 2d360f0

Browse files
fix: don't cancel text-area wheel event unnecessarily (#3495) (#3496)
Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
1 parent 6a8b5a5 commit 2d360f0

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

packages/text-area/src/vaadin-text-area.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,13 @@ export class TextArea extends InputFieldMixin(ThemableMixin(ElementMixin(Polymer
201201
// event, scrolling manually and then synchronously updating the scroll position CSS variable
202202
// allows us to avoid some jumpy behavior that would occur on wheel otherwise.
203203
this._inputField.addEventListener('wheel', (e) => {
204-
e.preventDefault();
204+
const scrollTopBefore = this._inputField.scrollTop;
205205
this._inputField.scrollTop += e.deltaY;
206-
this.__scrollPositionUpdated();
206+
207+
if (scrollTopBefore !== this._inputField.scrollTop) {
208+
e.preventDefault();
209+
this.__scrollPositionUpdated();
210+
}
207211
});
208212

209213
this._updateHeight();

packages/text-area/test/text-area.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ describe('text-area', () => {
362362
expect(e.defaultPrevented).to.be.true;
363363
});
364364

365+
it('should not cancel wheel event if text area is not scrolled', () => {
366+
const e = wheel({ deltaY: -10 });
367+
expect(e.defaultPrevented).to.be.false;
368+
});
369+
365370
it('should update value on resize', async () => {
366371
inputField.scrollTop = 10;
367372
await nextFrame();

0 commit comments

Comments
 (0)