Skip to content
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

**Feature:** Hotkey hook #956

Merged
merged 4 commits into from
Mar 11, 2019
Merged

**Feature:** Hotkey hook #956

merged 4 commits into from
Mar 11, 2019

Conversation

mpotomin
Copy link
Contributor

Summary

Adds a hook, that allows intercepting a hotkey combination in an HTML element and triggering a callback in reponse

Related issue

PAN-33

To be tested

  • Things still look good in the demo (no visual regressions are expected)
  • Various hotkey combinations, suggested ion the doc, work as expected
  • Hotkeys invoke only within the expected scope

@mpotomin mpotomin requested a review from TejasQ March 10, 2019 16:06
@TejasQ TejasQ self-assigned this Mar 11, 2019
Copy link
Contributor

@TejasQ TejasQ left a comment

Choose a reason for hiding this comment

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

Tiny changeset to finish this

const useRef = require("react").useRef

const Component1 = () => {
const scope = useRef(null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use containerNode here.

src/useHotkey/index.ts Show resolved Hide resolved
// Meta
fireEvent(rendered, new KeyboardEvent("keydown", { key: "o", metaKey: true }))
expect(callbackCtrl.mock.calls.length).toBe(1)
expect(callbackShift.mock.calls.length).toBe(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

To have been called with autocomplete

Copy link
Contributor

@TejasQ TejasQ left a comment

Choose a reason for hiding this comment

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

@mpotomin is the future

@TejasQ TejasQ merged commit 454003b into master Mar 11, 2019
@TejasQ TejasQ deleted the use-hotkey-hook branch March 11, 2019 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants