Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

fix(md-calendar): boundKeyHandler preventDefault on other input elements #9746

Merged
merged 9 commits into from
Nov 16, 2016

Conversation

NgaiKaKit
Copy link
Contributor

If use the md-calendar directly in the body without datepicker, boundKeyHandler will disable some keyEvent on other input elements in the page. So only apply the handleKeyEvent on the document.body when the md-calendar is inside datepicker. Otherwise, apply on the calendar element only.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@NgaiKaKit NgaiKaKit changed the title md-calendar: boundKeyHandler preventDefault on other input elements fix(md-calendar): boundKeyHandler preventDefault on other input elements Oct 4, 2016
@crisbeto crisbeto self-assigned this Oct 4, 2016
@crisbeto crisbeto added the needs: review This PR is waiting on review from the team label Oct 4, 2016
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR. I actually did something similar in #9641, although it shouldn't hurt fixing it until #9641 is merged. Your tests seem to be failing, because they're still dispatching key events to the body, instead of the element. See https://github.com/angular/material/blob/master/src/components/datepicker/js/calendar.spec.js#L116

// otherwise apply on the calendar element only.

if (this.$element.parent().hasClass('md-datepicker-calendar')) {
handleKeyElement = angular.element(document.body);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a little more readable if you defined the handleKeyEvent in an else block. Also you can refer to this.$element as just $element:

if ($element.parent().hasClass('md-datepicker-calendar')) {
  handleKeyElement = angular.element(document.body);
} else {
  handleKeyElement = $element;
}

@crisbeto crisbeto added in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs needs: work labels Oct 4, 2016
@@ -113,7 +113,14 @@ describe('md-calendar', function() {
function dispatchKeyEvent(keyCode, opt_modifiers) {
var mod = opt_modifiers || {};

angular.element(document.body).triggerHandler({
var dispatchElement;
if (angular.element(element).parent().hasClass('md-datepicker-calendar')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this check. The calendar here will always be on it's own (without the datepicker).

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @ThomasBurleson. @NgaiKaKit could you try signing the CLA again? Otherwise the PR can't be merged.

@crisbeto crisbeto removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs needs: work labels Oct 9, 2016
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

@ThomasBurleson ThomasBurleson added needs: presubmit and removed needs: review This PR is waiting on review from the team labels Oct 17, 2016
@ThomasBurleson ThomasBurleson added this to the 1.1.2 milestone Oct 17, 2016
@kara kara added pr: merge ready This PR is ready for a caretaker to review and removed needs: presubmit labels Nov 16, 2016
@kara kara merged commit b903153 into angular:master Nov 16, 2016
@angular angular deleted a comment from googlebot Feb 7, 2018
@angular angular deleted a comment from googlebot Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr: merge ready This PR is ready for a caretaker to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants