Skip to content

Commit

Permalink
fix: allow helper disallowed char patterns set for input (#7521) (#7526)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaadin-bot authored Jul 10, 2024
1 parent d89fa78 commit 89fcc31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/field-base/src/input-control-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
11 changes: 11 additions & 0 deletions packages/field-base/test/input-control-mixin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(`<input type="checkbox" slot="helper"/>`);
element.appendChild(checkbox);
checkbox.focus();

await sendKeys({ press: 'Space' });

expect(checkbox.checked).to.be.true;
});
});

const fireDropEvent = (draggedText) => {
Expand Down

0 comments on commit 89fcc31

Please sign in to comment.