Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

fix(tooltip): handle esc keydown event #2164

Merged
merged 9 commits into from
Apr 13, 2019

Conversation

dakahn
Copy link
Contributor

@dakahn dakahn commented Apr 5, 2019

adds a check in the handleKeyPress method that closes the tooltip if escape is pressed.

ref #2076

to test

open the tool tip and press escape. the tooltip should close.

@netlify
Copy link

netlify bot commented Apr 5, 2019

Deploy preview for carbon-components-react ready!

Built with commit 78c922b

https://deploy-preview-2164--carbon-components-react.netlify.com

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

LGTM 👍 - Thanks @dakahn!

@@ -374,6 +374,11 @@ class Tooltip extends Component {
handleKeyPress = evt => {
const key = evt.key || evt.which;

if (key === 'Escape' || key === 27) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (key === 'Escape' || key === 27) {
if (key === 'Escape' || key === 'Esc' || key === 27) {

Talking with @vpicone revealed that evt.key yields Esc in IE and looks that we should cover that.

Copy link
Member

Choose a reason for hiding this comment

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

would we want to also update and use these helper functions https://github.com/IBM/carbon-components-react/blob/master/src/tools/key.js?

Copy link
Contributor

Choose a reason for hiding this comment

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

@emyarod Good point - I think it makes sense to me.

@asudoh
Copy link
Contributor

asudoh commented Apr 11, 2019

Thanks @dakahn for the update and my apologies for being late on this - Updated code basically looks good to me, could you please look at the test failure?

@asudoh
Copy link
Contributor

asudoh commented Apr 13, 2019

The updated code LGTM 👍 - Thanks @dakahn!

@asudoh asudoh merged commit 2fbe6af into carbon-design-system:master Apr 13, 2019
@vpicone vpicone mentioned this pull request Apr 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants