-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add hotkey to open selected notification in new tab #1240
Conversation
Co-Authored-By: Tyler Madsen <madsen.tyler@gmail.com> Co-Authored-By: Alex Barnes <abarnes26@users.noreply.github.com>
Co-Authored-By: Tyler Madsen <madsen.tyler@gmail.com> Co-Authored-By: Alex Barnes <abarnes26@users.noreply.github.com>
Co-Authored-By: Tyler Madsen <madsen.tyler@gmail.com> Co-Authored-By: Alex Barnes <abarnes26@users.noreply.github.com>
|
||
document.addEventListener('keyup', event => { | ||
const notification = select('.js-notification, .navigation-focus'); | ||
const isO = (event.key === 'O'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be inline in the if
statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, definitely..
document.addEventListener('keyup', event => { | ||
const notification = select('.js-notification, .navigation-focus'); | ||
const isO = (event.key === 'O'); | ||
const url = document.querySelector('.navigation-focus').querySelector('a'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document.querySelector('.navigation-focus').querySelector('a');
=> document.querySelector('.navigation-focus a');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better, thanks
import {registerShortcut} from './improve-shortcut-help'; | ||
|
||
export default function () { | ||
registerShortcut('notifications', 'shift o', 'Open Notification in New Tab'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open Notification in New Tab
=> Open selected notification in new tab
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sindresorhus is definitely more clear, thanks for taking the time to review!
Co-Authored-By: Tyler Madsen <madsen.tyler@gmail.com> Co-Authored-By: Alex Barnes <abarnes26@users.noreply.github.com>
@bfred-it |
@bfred-it 'CTRL + Enter' Doesn't work on my Mac |
Windows, I imagine? So this feature is Mac-specific + should be activated via ctrl enter as well, unless anyone else can replicate on Mac somehow too. |
@bfred-it windows I am not sure it worked. Where should I be doing it on the notification screen? |
On the notification screen, select a notification via |
How would I go about adding a listener for 'ctrl - enter'? Is there a way to listen for key combos? From what I'm seeing is that the keyCode is the same when I press enter whether or not I have ctrl pressed. |
@bfred-it I'm slow lol. I forgot it should open in a new tab. Nope it's not working for me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be renamed to be non-notifications-specific. It can work across the site.
window.open(url, '_blank'); | ||
document.addEventListener('keypress', event => { | ||
const selected = document.querySelector('.navigation-focus .js-navigation-open[href]'); | ||
if (selected && event.key === 'O') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, that's a much more concise way of doing it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you forgot the .js
Thanks @yakov116! |
@bfred-it Added description and gif of interaction to the readme |
@Maxscores thanks for this PR ^_^ |
Is it possible to open the new tab but stay in the notifications? My use case is that I go through all of the notifications, select the ones I want to go deeper into with |
Another things is that when you press |
Possible, but you probably shouldn't stab anyone before reading their messages. Yes, I'd prefer the same. Instead of
Can be fixed by replacing the PR welcome! |
Should not we just click on the |
cc @bfred-it |
Each click triggers an ajax request. We should probably use |
Fixes #1110
Adds feature where a user can use 'shift o' on a highlighted notification to open the notification in a new tab.