Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Fixed action button keyup also triggering click event #1448

Merged
merged 2 commits into from
Feb 9, 2018

Conversation

Blackbaud-SteveBrush
Copy link
Member

Addresses: #994

The keyup event also triggers a click event.

When the modal closes, it immediately focuses the trigger element. If the close button was triggered using the enter key, it will fire the keyup event on the newly focused trigger button. To avoid this behavior, we can instead register keydown on the action button, to prevent the close button's keyup from also being triggered.

To test, add an action button to the modal demo component and serve.

<sky-action-button (actionClick)="openModal('defaultModal')">
  <sky-action-button-header>
    Open modal with an action button
  </sky-action-button-header>
</sky-action-button>

@Blackbaud-SteveBrush
Copy link
Member Author

@Blackbaud-BobbyEarl This is a much simpler approach to the previous pull request. Let me know your thoughts!

Old PR: #1255

@@ -2,7 +2,7 @@
class="sky-action-button sky-btn-default"
role="button"
(click)="buttonClicked()"
(keyup)="enterPress($event)"
(keydown.enter)="enterPress()"
Copy link
Member Author

Choose a reason for hiding this comment

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

Only change: using keydown instead of keyup.

@codecov-io
Copy link

codecov-io commented Jan 30, 2018

Codecov Report

Merging #1448 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1448   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files         382     382           
  Lines        7400    7399    -1     
  Branches      946     945    -1     
======================================
- Hits         7400    7399    -1
Impacted Files Coverage Δ
...c/modules/action-button/action-button.component.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update deee55e...fb3e11d. Read the comment docs.

@Blackbaud-SteveBrush Blackbaud-SteveBrush merged commit 483c44e into master Feb 9, 2018
@Blackbaud-SteveBrush Blackbaud-SteveBrush deleted the fix-action-button-keyup branch February 9, 2018 21:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants