Skip to content

Commit 89fcc31

Browse files
authored
fix: allow helper disallowed char patterns set for input (#7521) (#7526)
1 parent d89fa78 commit 89fcc31

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/field-base/src/input-control-mixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export const InputControlMixin = (superclass) =>
189189
_onKeyDown(event) {
190190
super._onKeyDown(event);
191191

192-
if (this.allowedCharPattern && !this.__shouldAcceptKey(event)) {
192+
if (this.allowedCharPattern && !this.__shouldAcceptKey(event) && event.target === this.inputElement) {
193193
event.preventDefault();
194194
this._markInputPrevented();
195195
}

packages/field-base/test/input-control-mixin.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
nextRender,
1111
nextUpdate,
1212
} from '@vaadin/testing-helpers';
13+
import { sendKeys } from '@web/test-runner-commands';
1314
import sinon from 'sinon';
1415
import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
1516
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
@@ -369,6 +370,16 @@ const runTests = (defineHelper, baseMixin) => {
369370
element._preventInputDebouncer.flush();
370371
expect(element.hasAttribute('input-prevented')).to.be.false;
371372
});
373+
374+
it('should not prevent input for other slotted inputs', async () => {
375+
const checkbox = fixtureSync(`<input type="checkbox" slot="helper"/>`);
376+
element.appendChild(checkbox);
377+
checkbox.focus();
378+
379+
await sendKeys({ press: 'Space' });
380+
381+
expect(checkbox.checked).to.be.true;
382+
});
372383
});
373384

374385
const fireDropEvent = (draggedText) => {

0 commit comments

Comments
 (0)