Skip to content

Commit

Permalink
Merge pull request #4649 from vdegenne:text-field-redispatch-event
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 554551590
  • Loading branch information
copybara-github committed Aug 7, 2023
2 parents cac4ced + 33987c3 commit 1f2f706
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions textfield/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export class TextFieldHarness extends Harness<TextField> {
if (!init) {
init = {
inputType: 'insertText',
composed: true,
bubbles: true,
isComposing: false,
data: charactersToAppend,
};
Expand All @@ -114,6 +116,8 @@ export class TextFieldHarness extends Harness<TextField> {
if (!init) {
init = {
inputType: 'deleteContentBackward',
composed: true,
bubbles: true,
isComposing: false,
data: deletedCharacters,
};
Expand Down
1 change: 0 additions & 1 deletion textfield/internal/text-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,6 @@ export abstract class TextField extends LitElement {
private handleInput(event: InputEvent) {
this.dirty = true;
this.value = (event.target as HTMLInputElement).value;
this.redispatchEvent(event);
}

private redispatchEvent(event: Event) {
Expand Down
5 changes: 4 additions & 1 deletion textfield/internal/text-field_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ describe('TextField', () => {
const inputHandler = jasmine.createSpy('inputHandler');
harness.element.addEventListener('input', inputHandler);

const event = new InputEvent('input');
const event = new InputEvent('input', {
composed: true,
bubbles: true,
});
input.dispatchEvent(event);

expect(inputHandler).toHaveBeenCalledWith(event);
Expand Down

0 comments on commit 1f2f706

Please sign in to comment.