-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(autocomplete): do not trigger submit on ENTER #3727
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -611,6 +611,24 @@ describe('MdAutocomplete', () => { | |
}); | ||
})); | ||
|
||
it('should not call the default input behaviour when an option is selected with ENTER', | ||
async(() => { | ||
fixture.whenStable().then(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need the |
||
fixture.componentInstance.trigger._handleKeydown(DOWN_ARROW_EVENT); | ||
|
||
fixture.whenStable().then(() => { | ||
fixture.detectChanges(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't need to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. I've removed the extra |
||
|
||
spyOn(ENTER_EVENT, 'preventDefault'); | ||
|
||
fixture.componentInstance.trigger._handleKeydown(ENTER_EVENT); | ||
fixture.detectChanges(); | ||
|
||
expect(ENTER_EVENT.preventDefault).toHaveBeenCalled(); | ||
}); | ||
}); | ||
})); | ||
|
||
it('should fill the text field, not select an option, when SPACE is entered', async(() => { | ||
fixture.whenStable().then(() => { | ||
typeInElement('New', input); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could shorten this to something like
should prevent the default enter key action
so it doesn't have to be on separate lines.