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

Misleading return value when registering duplicate value #72

Open
fynnfeldpausch opened this issue Dec 16, 2022 · 1 comment
Open

Misleading return value when registering duplicate value #72

fynnfeldpausch opened this issue Dec 16, 2022 · 1 comment

Comments

@fynnfeldpausch
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

If a duplicate shortcut is registered, the library logs an error to the console and resolves with an observable holding null (https://github.com/ngneat/hotkeys/blob/master/projects/ngneat/hotkeys/src/lib/hotkeys.service.ts#L160). This leads to unexpected behaviour, because the callback to execute when the shortcut has been pressed, is still executed but the event is null. This becomes especially confusing, because of the of(null) the callback is immediately executed, even if the key has not been pressed.

Expected behavior

The observable should error, if an error occurs, thus not executing the callback.

Minimal reproduction of the problem with instructions

Just register a callback twice.

Environment


Angular version: 15.x

Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
@NetanelBasal
Copy link
Member

You're welcome to create a PR.

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

No branches or pull requests

2 participants