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

Invoke callbacks with node as the first parameter #27

Merged
merged 3 commits into from
Jan 19, 2022
Merged

Invoke callbacks with node as the first parameter #27

merged 3 commits into from
Jan 19, 2022

Conversation

gtm-nayan
Copy link
Collaborator

Allows for an easier way of performing other actions on the element that the action is applied on.

Example use cases:

  • Scrolling a div with overflow when a key is pressed.
  • Focusing elements that don't respond to clicks (eg. select)

Currently this can be achieved by binding the current node to a variable in the consumer component, and then using that variable in the callback. With this change, the callback will receive the node as a parameter allowing something like
(node) => node.focus()

@swyxio
Copy link
Owner

swyxio commented Jan 19, 2022

very cool ty!

src/shortcut.ts Outdated Show resolved Hide resolved
@swyxio swyxio merged commit 8093bb6 into swyxio:main Jan 19, 2022
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