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

feat: adds a global modifier to the directive #96

Merged
merged 1 commit into from
Feb 2, 2025

Conversation

lucasnbsb
Copy link
Contributor

Adds a prop to the directive that causes the listener to be set in the document element

closes #35

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines: CONTRIBUTING.md#commit
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The directive only fires the hotkey event when it's host element is active

Issue Number: #35

What is the new behavior?

A new isGlobal prop in the directive causes the hotkey event to be fired whenever it's allowed

Does this PR introduce a breaking change?

[ ] Yes
[X] No

Other information

Adds a prop to the directive that causes the listener to be set in the document element

closes ngneat#35
Copy link

stackblitz bot commented Feb 2, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@lucasnbsb
Copy link
Contributor Author

Hi @NetanelBasal, i saw this old issue that aligned with the expectation i had when first using the directive and decided to give it a shot.

The solution was to add a prop that makes the listener be set in the Document, the lifecycle of the hotkey is still tied to the directive, so it goes away with the host element

@NetanelBasal NetanelBasal merged commit 10ce51b into ngneat:master Feb 2, 2025
1 check passed
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.

Setting [hotkeys] on a button only activates hotkey if focused on the button
2 participants