From 030c29dd6477a05c3990d9d1e40ab24db7b6e981 Mon Sep 17 00:00:00 2001 From: Vaadin Bot Date: Wed, 10 Jul 2024 11:07:23 +0200 Subject: [PATCH] fix: allow helper disallowed char patterns set for input (#7521) (#7527) --- packages/field-base/src/input-control-mixin.js | 2 +- packages/field-base/test/input-control-mixin.test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/field-base/src/input-control-mixin.js b/packages/field-base/src/input-control-mixin.js index 64990d958e..3b485d7ad5 100644 --- a/packages/field-base/src/input-control-mixin.js +++ b/packages/field-base/src/input-control-mixin.js @@ -189,7 +189,7 @@ export const InputControlMixin = (superclass) => _onKeyDown(event) { super._onKeyDown(event); - if (this.allowedCharPattern && !this.__shouldAcceptKey(event)) { + if (this.allowedCharPattern && !this.__shouldAcceptKey(event) && event.target === this.inputElement) { event.preventDefault(); this._markInputPrevented(); } diff --git a/packages/field-base/test/input-control-mixin.test.js b/packages/field-base/test/input-control-mixin.test.js index 9380a7e620..301c8bd0af 100644 --- a/packages/field-base/test/input-control-mixin.test.js +++ b/packages/field-base/test/input-control-mixin.test.js @@ -10,6 +10,7 @@ import { nextRender, nextUpdate, } from '@vaadin/testing-helpers'; +import { sendKeys } from '@web/test-runner-commands'; import sinon from 'sinon'; import { isTouch } from '@vaadin/component-base/src/browser-utils.js'; import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js'; @@ -369,6 +370,16 @@ const runTests = (defineHelper, baseMixin) => { element._preventInputDebouncer.flush(); expect(element.hasAttribute('input-prevented')).to.be.false; }); + + it('should not prevent input for other slotted inputs', async () => { + const checkbox = fixtureSync(``); + element.appendChild(checkbox); + checkbox.focus(); + + await sendKeys({ press: 'Space' }); + + expect(checkbox.checked).to.be.true; + }); }); const fireDropEvent = (draggedText) => {